On Tue, Aug 18, 2026 at 11:14 PM Alexander Graf <[email protected]> wrote: > > 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 <[email protected]>
Acked-by: Eugenio Pérez <[email protected]> > Assisted-by: Kiro:claude-opus-5 checkpatch > Signed-off-by: Alexander Graf <[email protected]> > --- > 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); > }; >

