• Si-Wei Liu's avatar
    vdpa/mlx5: implement .reset_map driver op · 2eacf4b5
    Si-Wei Liu authored
    Since commit 6f5312f8 ("vdpa/mlx5: Add support for running with
    virtio_vdpa"), mlx5_vdpa starts with preallocate 1:1 DMA MR at device
    creation time. This 1:1 DMA MR will be implicitly destroyed while the
    first .set_map call is invoked, in which case callers like vhost-vdpa
    will start to set up custom mappings. When the .reset callback is
    invoked, the custom mappings will be cleared and the 1:1 DMA MR will be
    re-created.
    
    In order to reduce excessive memory mapping cost in live migration, it
    is desirable to decouple the vhost-vdpa IOTLB abstraction from the
    virtio device life cycle, i.e. mappings can be kept around intact across
    virtio device reset. Leverage the .reset_map callback, which is meant to
    destroy the regular MR (including cvq mapping) on the given ASID and
    recreate the initial DMA mapping. That way, the device .reset op runs
    free from having to maintain and clean up memory mappings by itself.
    
    Additionally, implement .compat_reset to cater for older userspace,
    which may wish to see mapping to be cleared during reset.
    Co-developed-by: default avatarDragos Tatulea <dtatulea@nvidia.com>
    Signed-off-by: default avatarDragos Tatulea <dtatulea@nvidia.com>
    Signed-off-by: default avatarSi-Wei Liu <si-wei.liu@oracle.com>
    Message-Id: <1697880319-4937-7-git-send-email-si-wei.liu@oracle.com>
    Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
    Tested-by: default avatarLei Yang <leiyang@redhat.com>
    2eacf4b5
mlx5_vdpa.h 4.11 KB