]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
virtio: introduce map ops in virtio core
authorJason Wang <jasowang@redhat.com>
Thu, 21 Aug 2025 06:46:38 +0000 (14:46 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 1 Oct 2025 11:24:43 +0000 (07:24 -0400)
commitbee8c7c24b737338216dc0f87d6c47a4abaf609a
tree538af5ec10b01177535873a5dad9d86e2049d02d
parent201e52ffe3349396303f741d098a9d285c52f44e
virtio: introduce map ops in virtio core

This patch introduces map operations for virtio device. Virtio used to
use DMA API which is not necessarily the case since some devices
doesn't do DMA. Instead of using tricks and abusing DMA API, let's
simply abstract the current mapping logic into a virtio specific
mapping operations. For the device or transport that doesn't do DMA,
they can implement their own mapping logic without the need to trick
DMA core. In this case the mapping metadata is opaque to the virtio
core that will be passed back to the transport or device specific map
operations. For other devices, DMA API will still be used, so map
token will still be the dma device to minimize the changeset and
performance impact.

The mapping operations are abstracted as a independent structure
instead of reusing virtio_config_ops. This allows the transport can
simply reuse the structure for lower layers like vDPA.

A set of new mapping helpers were introduced for the device that want
to do mapping by themselves.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20250821064641.5025-7-jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Lei Yang <leiyang@redhat.com>
Reviewed-by: Eugenio Pérez <eperezma@redhat.com>
drivers/virtio/virtio_ring.c
drivers/virtio/virtio_vdpa.c
include/linux/virtio.h
include/linux/virtio_config.h