Commit fc89d7fb authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull virtio fixes from Michael Tsirkin:
 "Some virtio / vhost / vdpa fixes accumulated so far"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
  tools/virtio: Ignore virtio-trace/trace-agent
  vdpa_sim: set last_used_idx as last_avail_idx in vdpasim_queue_ready
  vhost-vdpa: free iommu domain after last use during cleanup
  vdpa/mlx5: should not activate virtq object when suspended
  vp_vdpa: fix the crash in hot unplug with vp_vdpa
parents eeac8ede ae43c20d
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -96,6 +96,7 @@ struct mlx5_vdpa_dev {
	struct mlx5_control_vq cvq;
	struct mlx5_control_vq cvq;
	struct workqueue_struct *wq;
	struct workqueue_struct *wq;
	unsigned int group2asid[MLX5_VDPA_NUMVQ_GROUPS];
	unsigned int group2asid[MLX5_VDPA_NUMVQ_GROUPS];
	bool suspended;
};
};


int mlx5_vdpa_alloc_pd(struct mlx5_vdpa_dev *dev, u32 *pdn, u16 uid);
int mlx5_vdpa_alloc_pd(struct mlx5_vdpa_dev *dev, u32 *pdn, u16 uid);
+5 −1
Original line number Original line Diff line number Diff line
@@ -2438,7 +2438,7 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev,
	if (err)
	if (err)
		goto err_mr;
		goto err_mr;


	if (!(mvdev->status & VIRTIO_CONFIG_S_DRIVER_OK))
	if (!(mvdev->status & VIRTIO_CONFIG_S_DRIVER_OK) || mvdev->suspended)
		goto err_mr;
		goto err_mr;


	restore_channels_info(ndev);
	restore_channels_info(ndev);
@@ -2606,6 +2606,7 @@ static int mlx5_vdpa_reset(struct vdpa_device *vdev)
	clear_vqs_ready(ndev);
	clear_vqs_ready(ndev);
	mlx5_vdpa_destroy_mr(&ndev->mvdev);
	mlx5_vdpa_destroy_mr(&ndev->mvdev);
	ndev->mvdev.status = 0;
	ndev->mvdev.status = 0;
	ndev->mvdev.suspended = false;
	ndev->cur_num_vqs = 0;
	ndev->cur_num_vqs = 0;
	ndev->mvdev.cvq.received_desc = 0;
	ndev->mvdev.cvq.received_desc = 0;
	ndev->mvdev.cvq.completed_desc = 0;
	ndev->mvdev.cvq.completed_desc = 0;
@@ -2852,6 +2853,8 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev)
	struct mlx5_vdpa_virtqueue *mvq;
	struct mlx5_vdpa_virtqueue *mvq;
	int i;
	int i;


	mlx5_vdpa_info(mvdev, "suspending device\n");

	down_write(&ndev->reslock);
	down_write(&ndev->reslock);
	ndev->nb_registered = false;
	ndev->nb_registered = false;
	mlx5_notifier_unregister(mvdev->mdev, &ndev->nb);
	mlx5_notifier_unregister(mvdev->mdev, &ndev->nb);
@@ -2861,6 +2864,7 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev)
		suspend_vq(ndev, mvq);
		suspend_vq(ndev, mvq);
	}
	}
	mlx5_vdpa_cvq_suspend(mvdev);
	mlx5_vdpa_cvq_suspend(mvdev);
	mvdev->suspended = true;
	up_write(&ndev->reslock);
	up_write(&ndev->reslock);
	return 0;
	return 0;
}
}
+11 −0
Original line number Original line Diff line number Diff line
@@ -68,6 +68,17 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
			  (uintptr_t)vq->device_addr);
			  (uintptr_t)vq->device_addr);


	vq->vring.last_avail_idx = last_avail_idx;
	vq->vring.last_avail_idx = last_avail_idx;

	/*
	 * Since vdpa_sim does not support receive inflight descriptors as a
	 * destination of a migration, let's set both avail_idx and used_idx
	 * the same at vq start.  This is how vhost-user works in a
	 * VHOST_SET_VRING_BASE call.
	 *
	 * Although the simple fix is to set last_used_idx at
	 * vdpasim_set_vq_state, it would be reset at vdpasim_queue_ready.
	 */
	vq->vring.last_used_idx = last_avail_idx;
	vq->vring.notify = vdpasim_vq_notify;
	vq->vring.notify = vdpasim_vq_notify;
}
}


+1 −1
Original line number Original line Diff line number Diff line
@@ -645,8 +645,8 @@ static void vp_vdpa_remove(struct pci_dev *pdev)
	struct virtio_pci_modern_device *mdev = NULL;
	struct virtio_pci_modern_device *mdev = NULL;


	mdev = vp_vdpa_mgtdev->mdev;
	mdev = vp_vdpa_mgtdev->mdev;
	vp_modern_remove(mdev);
	vdpa_mgmtdev_unregister(&vp_vdpa_mgtdev->mgtdev);
	vdpa_mgmtdev_unregister(&vp_vdpa_mgtdev->mgtdev);
	vp_modern_remove(mdev);
	kfree(vp_vdpa_mgtdev->mgtdev.id_table);
	kfree(vp_vdpa_mgtdev->mgtdev.id_table);
	kfree(mdev);
	kfree(mdev);
	kfree(vp_vdpa_mgtdev);
	kfree(vp_vdpa_mgtdev);
+2 −1
Original line number Original line Diff line number Diff line
@@ -1169,6 +1169,7 @@ static int vhost_vdpa_alloc_domain(struct vhost_vdpa *v)


err_attach:
err_attach:
	iommu_domain_free(v->domain);
	iommu_domain_free(v->domain);
	v->domain = NULL;
	return ret;
	return ret;
}
}


@@ -1213,6 +1214,7 @@ static void vhost_vdpa_cleanup(struct vhost_vdpa *v)
			vhost_vdpa_remove_as(v, asid);
			vhost_vdpa_remove_as(v, asid);
	}
	}


	vhost_vdpa_free_domain(v);
	vhost_dev_cleanup(&v->vdev);
	vhost_dev_cleanup(&v->vdev);
	kfree(v->vdev.vqs);
	kfree(v->vdev.vqs);
}
}
@@ -1285,7 +1287,6 @@ static int vhost_vdpa_release(struct inode *inode, struct file *filep)
	vhost_vdpa_clean_irq(v);
	vhost_vdpa_clean_irq(v);
	vhost_vdpa_reset(v);
	vhost_vdpa_reset(v);
	vhost_dev_stop(&v->vdev);
	vhost_dev_stop(&v->vdev);
	vhost_vdpa_free_domain(v);
	vhost_vdpa_config_put(v);
	vhost_vdpa_config_put(v);
	vhost_vdpa_cleanup(v);
	vhost_vdpa_cleanup(v);
	mutex_unlock(&d->mutex);
	mutex_unlock(&d->mutex);
Loading