Commit bf897d26 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull virtio updates from Michael Tsirkin:
 "Just fixes and cleanups this time around. The mapping cleanups are
  preparing the ground for new features, though"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
  virtio-vdpa: Drop redundant conversion to bool
  vduse: Use fixed 4KB bounce pages for non-4KB page size
  vduse: switch to use virtio map API instead of DMA API
  vdpa: introduce map ops
  vdpa: support virtio_map
  virtio: introduce map ops in virtio core
  virtio_ring: rename dma_handle to map_handle
  virtio: introduce virtio_map container union
  virtio: rename dma helpers
  virtio_ring: switch to use dma_{map|unmap}_page()
  virtio_ring: constify virtqueue pointer for DMA helpers
  virtio_balloon: Remove redundant __GFP_NOWARN
  vhost: vringh: Fix copy_to_iter return value check
  vhost: vringh: Modify the return value check
parents 55a42f78 ed9f3ab9
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -962,7 +962,7 @@ static void virtnet_rq_unmap(struct receive_queue *rq, void *buf, u32 len)
	if (dma->need_sync && len) {
		offset = buf - (head + sizeof(*dma));

		virtqueue_dma_sync_single_range_for_cpu(rq->vq, dma->addr,
		virtqueue_map_sync_single_range_for_cpu(rq->vq, dma->addr,
							offset, len,
							DMA_FROM_DEVICE);
	}
@@ -970,7 +970,7 @@ static void virtnet_rq_unmap(struct receive_queue *rq, void *buf, u32 len)
	if (dma->ref)
		return;

	virtqueue_dma_unmap_single_attrs(rq->vq, dma->addr, dma->len,
	virtqueue_unmap_single_attrs(rq->vq, dma->addr, dma->len,
				     DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC);
	put_page(page);
}
@@ -1038,13 +1038,13 @@ static void *virtnet_rq_alloc(struct receive_queue *rq, u32 size, gfp_t gfp)

		dma->len = alloc_frag->size - sizeof(*dma);

		addr = virtqueue_dma_map_single_attrs(rq->vq, dma + 1,
		addr = virtqueue_map_single_attrs(rq->vq, dma + 1,
						  dma->len, DMA_FROM_DEVICE, 0);
		if (virtqueue_dma_mapping_error(rq->vq, addr))
		if (virtqueue_map_mapping_error(rq->vq, addr))
			return NULL;

		dma->addr = addr;
		dma->need_sync = virtqueue_dma_need_sync(rq->vq, addr);
		dma->need_sync = virtqueue_map_need_sync(rq->vq, addr);

		/* Add a reference to dma to prevent the entire dma from
		 * being released during error handling. This reference
@@ -5942,9 +5942,9 @@ static int virtnet_xsk_pool_enable(struct net_device *dev,
	if (!rq->xsk_buffs)
		return -ENOMEM;

	hdr_dma = virtqueue_dma_map_single_attrs(sq->vq, &xsk_hdr, vi->hdr_len,
	hdr_dma = virtqueue_map_single_attrs(sq->vq, &xsk_hdr, vi->hdr_len,
					     DMA_TO_DEVICE, 0);
	if (virtqueue_dma_mapping_error(sq->vq, hdr_dma)) {
	if (virtqueue_map_mapping_error(sq->vq, hdr_dma)) {
		err = -ENOMEM;
		goto err_free_buffs;
	}
@@ -5973,7 +5973,7 @@ static int virtnet_xsk_pool_enable(struct net_device *dev,
err_rq:
	xsk_pool_dma_unmap(pool, 0);
err_xsk_map:
	virtqueue_dma_unmap_single_attrs(rq->vq, hdr_dma, vi->hdr_len,
	virtqueue_unmap_single_attrs(rq->vq, hdr_dma, vi->hdr_len,
				     DMA_TO_DEVICE, 0);
err_free_buffs:
	kvfree(rq->xsk_buffs);
@@ -6001,7 +6001,7 @@ static int virtnet_xsk_pool_disable(struct net_device *dev, u16 qid)

	xsk_pool_dma_unmap(pool, 0);

	virtqueue_dma_unmap_single_attrs(sq->vq, sq->xsk_hdr_dma_addr,
	virtqueue_unmap_single_attrs(sq->vq, sq->xsk_hdr_dma_addr,
				     vi->hdr_len, DMA_TO_DEVICE, 0);
	kvfree(rq->xsk_buffs);

+1 −7
Original line number Diff line number Diff line
@@ -34,13 +34,7 @@ config VDPA_SIM_BLOCK

config VDPA_USER
	tristate "VDUSE (vDPA Device in Userspace) support"
	depends on EVENTFD && MMU && HAS_DMA
	#
	# This driver incorrectly tries to override the dma_ops.  It should
	# never have done that, but for now keep it working on architectures
	# that use dma ops
	#
	depends on ARCH_HAS_DMA_OPS
	depends on EVENTFD && MMU
	select VHOST_IOTLB
	select IOMMU_IOVA
	help
+3 −2
Original line number Diff line number Diff line
@@ -478,7 +478,8 @@ static int eni_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
		return ret;

	eni_vdpa = vdpa_alloc_device(struct eni_vdpa, vdpa,
				     dev, &eni_vdpa_ops, 1, 1, NULL, false);
				     dev, &eni_vdpa_ops, NULL,
				     1, 1, NULL, false);
	if (IS_ERR(eni_vdpa)) {
		ENI_ERR(pdev, "failed to allocate vDPA structure\n");
		return PTR_ERR(eni_vdpa);
@@ -496,7 +497,7 @@ static int eni_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
	pci_set_master(pdev);
	pci_set_drvdata(pdev, eni_vdpa);

	eni_vdpa->vdpa.dma_dev = &pdev->dev;
	eni_vdpa->vdpa.vmap.dma_dev = &pdev->dev;
	eni_vdpa->queues = eni_vdpa_get_num_queues(eni_vdpa);

	eni_vdpa->vring = devm_kcalloc(&pdev->dev, eni_vdpa->queues,
+3 −2
Original line number Diff line number Diff line
@@ -705,7 +705,8 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
	vf = &ifcvf_mgmt_dev->vf;
	pdev = vf->pdev;
	adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
				    &pdev->dev, &ifc_vdpa_ops, 1, 1, NULL, false);
				    &pdev->dev, &ifc_vdpa_ops,
				    NULL, 1, 1, NULL, false);
	if (IS_ERR(adapter)) {
		IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
		return PTR_ERR(adapter);
@@ -713,7 +714,7 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,

	ifcvf_mgmt_dev->adapter = adapter;
	adapter->pdev = pdev;
	adapter->vdpa.dma_dev = &pdev->dev;
	adapter->vdpa.vmap.dma_dev = &pdev->dev;
	adapter->vdpa.mdev = mdev;
	adapter->vf = vf;
	vdpa_dev = &adapter->vdpa;
+2 −2
Original line number Diff line number Diff line
@@ -378,7 +378,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
	u64 pa, offset;
	u64 paend;
	struct scatterlist *sg;
	struct device *dma = mvdev->vdev.dma_dev;
	struct device *dma = mvdev->vdev.vmap.dma_dev;

	for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1);
	     map; map = vhost_iotlb_itree_next(map, mr->start, mr->end - 1)) {
@@ -432,7 +432,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr

static void unmap_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr)
{
	struct device *dma = mvdev->vdev.dma_dev;
	struct device *dma = mvdev->vdev.vmap.dma_dev;

	destroy_direct_mr(mvdev, mr);
	dma_unmap_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0);
Loading