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,
"Parav Pandit" <parav@nvidia.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH v2 01/12] virtio_ring: remove the unused map sync API
Date: Tue, 18 Aug 2026 21:14:14 +0000 [thread overview]
Message-ID: <20260818211425.91009-2-graf@amazon.com> (raw)
In-Reply-To: <20260818211425.91009-1-graf@amazon.com>
virtqueue_map_need_sync(), virtqueue_map_sync_single_range_for_cpu() and
virtqueue_map_sync_single_range_for_device() are exported, but no driver
in the tree calls them. They are the only path into the sync members of
struct virtio_map_ops, so whoever implements that struct next has to
decide what those members do with no caller to learn it from.
Remove the three functions, their prototypes and their exports, and the
DMA sync shims that the virtio userspace harness kept for them. With
this, virtio_ring no longer exports a way to sync a mapping.
Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Assisted-by: Kiro:claude-opus-5 checkpatch
Signed-off-by: Alexander Graf <graf@amazon.com>
---
drivers/virtio/virtio_ring.c | 89 --------------------------------
include/linux/virtio.h | 8 ---
tools/virtio/linux/dma-mapping.h | 7 ---
3 files changed, 104 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index b438dc2ce1b8..ea8e774b6d8e 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -3890,94 +3890,5 @@ int virtqueue_map_mapping_error(const struct virtqueue *_vq, dma_addr_t addr)
}
EXPORT_SYMBOL_GPL(virtqueue_map_mapping_error);
-/**
- * virtqueue_map_need_sync - check a dma address needs sync
- * @_vq: the struct virtqueue we're talking about.
- * @addr: DMA address
- *
- * Check if the dma address mapped by the virtqueue_map_* APIs needs to be
- * synchronized
- *
- * return bool
- */
-bool virtqueue_map_need_sync(const struct virtqueue *_vq, dma_addr_t addr)
-{
- const struct vring_virtqueue *vq = to_vvq(_vq);
- struct virtio_device *vdev = _vq->vdev;
-
- if (!vq->use_map_api)
- return false;
-
- if (vdev->map)
- return vdev->map->need_sync(vq->map, addr);
- else
- return dma_need_sync(vring_dma_dev(vq), addr);
-}
-EXPORT_SYMBOL_GPL(virtqueue_map_need_sync);
-
-/**
- * virtqueue_map_sync_single_range_for_cpu - map sync for cpu
- * @_vq: the struct virtqueue we're talking about.
- * @addr: DMA address
- * @offset: DMA address offset
- * @size: buf size for sync
- * @dir: DMA direction
- *
- * Before calling this function, use virtqueue_map_need_sync() to confirm that
- * the DMA address really needs to be synchronized
- *
- */
-void virtqueue_map_sync_single_range_for_cpu(const struct virtqueue *_vq,
- dma_addr_t addr,
- unsigned long offset, size_t size,
- enum dma_data_direction dir)
-{
- const struct vring_virtqueue *vq = to_vvq(_vq);
- struct virtio_device *vdev = _vq->vdev;
-
- if (!vq->use_map_api)
- return;
-
- if (vdev->map)
- vdev->map->sync_single_for_cpu(vq->map,
- addr + offset, size, dir);
- else
- dma_sync_single_range_for_cpu(vring_dma_dev(vq),
- addr, offset, size, dir);
-}
-EXPORT_SYMBOL_GPL(virtqueue_map_sync_single_range_for_cpu);
-
-/**
- * virtqueue_map_sync_single_range_for_device - map sync for device
- * @_vq: the struct virtqueue we're talking about.
- * @addr: DMA address
- * @offset: DMA address offset
- * @size: buf size for sync
- * @dir: DMA direction
- *
- * Before calling this function, use virtqueue_map_need_sync() to confirm that
- * the DMA address really needs to be synchronized
- */
-void virtqueue_map_sync_single_range_for_device(const struct virtqueue *_vq,
- dma_addr_t addr,
- unsigned long offset, size_t size,
- enum dma_data_direction dir)
-{
- const struct vring_virtqueue *vq = to_vvq(_vq);
- struct virtio_device *vdev = _vq->vdev;
-
- if (!vq->use_map_api)
- return;
-
- if (vdev->map)
- vdev->map->sync_single_for_device(vq->map,
- addr + offset,
- size, dir);
- else
- dma_sync_single_range_for_device(vring_dma_dev(vq), addr,
- offset, size, dir);
-}
-EXPORT_SYMBOL_GPL(virtqueue_map_sync_single_range_for_device);
-
MODULE_DESCRIPTION("Virtio ring implementation");
MODULE_LICENSE("GPL");
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 93e573c56563..3122fc52a7c3 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -312,14 +312,6 @@ void virtqueue_unmap_single_attrs(const struct virtqueue *_vq, dma_addr_t addr,
unsigned long attrs);
int virtqueue_map_mapping_error(const struct virtqueue *_vq, dma_addr_t addr);
-bool virtqueue_map_need_sync(const struct virtqueue *_vq, dma_addr_t addr);
-void virtqueue_map_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_map_sync_single_range_for_device(const struct virtqueue *_vq, dma_addr_t addr,
- unsigned long offset, size_t size,
- enum dma_data_direction dir);
-
#ifdef CONFIG_VIRTIO_DEBUG
void virtio_debug_device_init(struct virtio_device *dev);
void virtio_debug_device_exit(struct virtio_device *dev);
diff --git a/tools/virtio/linux/dma-mapping.h b/tools/virtio/linux/dma-mapping.h
index b9fc5e8338e3..eae160ce7142 100644
--- a/tools/virtio/linux/dma-mapping.h
+++ b/tools/virtio/linux/dma-mapping.h
@@ -36,16 +36,9 @@ enum dma_data_direction {
#define sg_dma_address(sg) (0)
#define sg_dma_len(sg) (0)
-#define dma_need_sync(v, a) (0)
#define dma_unmap_single_attrs(d, a, s, r, t) do { \
(void)(d); (void)(a); (void)(s); (void)(r); (void)(t); \
} while (0)
-#define dma_sync_single_range_for_cpu(d, a, o, s, r) do { \
- (void)(d); (void)(a); (void)(o); (void)(s); (void)(r); \
-} while (0)
-#define dma_sync_single_range_for_device(d, a, o, s, r) do { \
- (void)(d); (void)(a); (void)(o); (void)(s); (void)(r); \
-} while (0)
#define dma_max_mapping_size(...) SIZE_MAX
/*
next prev parent reply other threads:[~2026-08-18 21:14 UTC|newest]
Thread overview: 14+ 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 ` Alexander Graf [this message]
2026-08-18 21:14 ` [PATCH v2 02/12] virtio: drop the sync operations from virtio_map_ops Alexander Graf
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:40 ` sashiko-bot
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-2-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=parav@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.