Commit 91aa6c41 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull virtio fixes from Michael Tsirkin:
 "Just a bunch of bugfixes all over the place"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (26 commits)
  virtio-mem: check if the config changed before fake offlining memory
  virtio-mem: keep retrying on offline_and_remove_memory() errors in Sub Block Mode (SBM)
  virtio-mem: convert most offline_and_remove_memory() errors to -EBUSY
  virtio-mem: remove unsafe unplug in Big Block Mode (BBM)
  pds_vdpa: fix up debugfs feature bit printing
  pds_vdpa: alloc irq vectors on DRIVER_OK
  pds_vdpa: clean and reset vqs entries
  pds_vdpa: always allow offering VIRTIO_NET_F_MAC
  pds_vdpa: reset to vdpa specified mac
  virtio-net: Zero max_tx_vq field for VIRTIO_NET_CTRL_MQ_HASH_CONFIG case
  vdpa/mlx5: Fix crash on shutdown for when no ndev exists
  vdpa/mlx5: Delete control vq iotlb in destroy_mr only when necessary
  vdpa/mlx5: Fix mr->initialized semantics
  vdpa/mlx5: Correct default number of queues when MQ is on
  virtio-vdpa: Fix cpumask memory leak in virtio_vdpa_find_vqs()
  vduse: Use proper spinlock for IRQ injection
  vdpa: Enable strict validation for netlinks ops
  vdpa: Add max vqp attr to vdpa_nl_policy for nlattr length check
  vdpa: Add queue index attr to vdpa_nl_policy for nlattr length check
  vdpa: Add features attr to vdpa_nl_policy for nlattr length check
  ...
parents 2ccdd1b1 f55484fd
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -22474,7 +22474,6 @@ L: virtualization@lists.linux-foundation.org
S:	Maintained
F:	drivers/block/virtio_blk.c
F:	drivers/scsi/virtio_scsi.c
F:	drivers/vhost/scsi.c
F:	include/uapi/linux/virtio_blk.h
F:	include/uapi/linux/virtio_scsi.h
@@ -22573,6 +22572,16 @@ F: include/linux/vhost_iotlb.h
F:	include/uapi/linux/vhost.h
F:	kernel/vhost_task.c
VIRTIO HOST (VHOST-SCSI)
M:	"Michael S. Tsirkin" <mst@redhat.com>
M:	Jason Wang <jasowang@redhat.com>
M:	Mike Christie <michael.christie@oracle.com>
R:	Paolo Bonzini <pbonzini@redhat.com>
R:	Stefan Hajnoczi <stefanha@redhat.com>
L:	virtualization@lists.linux-foundation.org
S:	Maintained
F:	drivers/vhost/scsi.c
VIRTIO I2C DRIVER
M:	Conghui Chen <conghui.chen@intel.com>
M:	Viresh Kumar <viresh.kumar@linaro.org>
+1 −1
Original line number Diff line number Diff line
@@ -2761,7 +2761,7 @@ static void virtnet_init_default_rss(struct virtnet_info *vi)
		vi->ctrl->rss.indirection_table[i] = indir_val;
	}

	vi->ctrl->rss.max_tx_vq = vi->curr_queue_pairs;
	vi->ctrl->rss.max_tx_vq = vi->has_rss ? vi->curr_queue_pairs : 0;
	vi->ctrl->rss.hash_key_length = vi->rss_key_size;

	netdev_rss_key_fill(vi->ctrl->rss.key, vi->rss_key_size);
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ struct mlx5_vdpa_mr {
	struct list_head head;
	unsigned long num_directs;
	unsigned long num_klms;
	/* state of dvq mr */
	bool initialized;

	/* serialize mkey creation and destruction */
@@ -121,6 +122,7 @@ int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *io
int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb,
			unsigned int asid);
void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev);
void mlx5_vdpa_destroy_mr_asid(struct mlx5_vdpa_dev *mvdev, unsigned int asid);

#define mlx5_vdpa_warn(__dev, format, ...)                                                         \
	dev_warn((__dev)->mdev->device, "%s:%d:(pid %d) warning: " format, __func__, __LINE__,     \
+70 −27
Original line number Diff line number Diff line
@@ -489,35 +489,73 @@ static void destroy_user_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_mr *mr
	}
}

void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev)
static void _mlx5_vdpa_destroy_cvq_mr(struct mlx5_vdpa_dev *mvdev, unsigned int asid)
{
	if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] != asid)
		return;

	prune_iotlb(mvdev);
}

static void _mlx5_vdpa_destroy_dvq_mr(struct mlx5_vdpa_dev *mvdev, unsigned int asid)
{
	struct mlx5_vdpa_mr *mr = &mvdev->mr;

	mutex_lock(&mr->mkey_mtx);
	if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] != asid)
		return;

	if (!mr->initialized)
		goto out;
		return;

	prune_iotlb(mvdev);
	if (mr->user_mr)
		destroy_user_mr(mvdev, mr);
	else
		destroy_dma_mr(mvdev, mr);

	mr->initialized = false;
out:
}

void mlx5_vdpa_destroy_mr_asid(struct mlx5_vdpa_dev *mvdev, unsigned int asid)
{
	struct mlx5_vdpa_mr *mr = &mvdev->mr;

	mutex_lock(&mr->mkey_mtx);

	_mlx5_vdpa_destroy_dvq_mr(mvdev, asid);
	_mlx5_vdpa_destroy_cvq_mr(mvdev, asid);

	mutex_unlock(&mr->mkey_mtx);
}

static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev,
				struct vhost_iotlb *iotlb, unsigned int asid)
void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev)
{
	mlx5_vdpa_destroy_mr_asid(mvdev, mvdev->group2asid[MLX5_VDPA_CVQ_GROUP]);
	mlx5_vdpa_destroy_mr_asid(mvdev, mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP]);
}

static int _mlx5_vdpa_create_cvq_mr(struct mlx5_vdpa_dev *mvdev,
				    struct vhost_iotlb *iotlb,
				    unsigned int asid)
{
	if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] != asid)
		return 0;

	return dup_iotlb(mvdev, iotlb);
}

static int _mlx5_vdpa_create_dvq_mr(struct mlx5_vdpa_dev *mvdev,
				    struct vhost_iotlb *iotlb,
				    unsigned int asid)
{
	struct mlx5_vdpa_mr *mr = &mvdev->mr;
	int err;

	if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] != asid)
		return 0;

	if (mr->initialized)
		return 0;

	if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid) {
	if (iotlb)
		err = create_user_mr(mvdev, iotlb);
	else
@@ -525,24 +563,29 @@ static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev,

	if (err)
		return err;

	mr->initialized = true;

	return 0;
}

	if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] == asid) {
		err = dup_iotlb(mvdev, iotlb);
static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev,
				struct vhost_iotlb *iotlb, unsigned int asid)
{
	int err;

	err = _mlx5_vdpa_create_dvq_mr(mvdev, iotlb, asid);
	if (err)
		return err;

	err = _mlx5_vdpa_create_cvq_mr(mvdev, iotlb, asid);
	if (err)
		goto out_err;
	}

	mr->initialized = true;
	return 0;

out_err:
	if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid) {
		if (iotlb)
			destroy_user_mr(mvdev, mr);
		else
			destroy_dma_mr(mvdev, mr);
	}
	_mlx5_vdpa_destroy_dvq_mr(mvdev, asid);

	return err;
}
+11 −15
Original line number Diff line number Diff line
@@ -2517,7 +2517,15 @@ static int mlx5_vdpa_set_driver_features(struct vdpa_device *vdev, u64 features)
	else
		ndev->rqt_size = 1;

	ndev->cur_num_vqs = 2 * ndev->rqt_size;
	/* Device must start with 1 queue pair, as per VIRTIO v1.2 spec, section
	 * 5.1.6.5.5 "Device operation in multiqueue mode":
	 *
	 * Multiqueue is disabled by default.
	 * The driver enables multiqueue by sending a command using class
	 * VIRTIO_NET_CTRL_MQ. The command selects the mode of multiqueue
	 * operation, as follows: ...
	 */
	ndev->cur_num_vqs = 2;

	update_cvq_info(mvdev);
	return err;
@@ -2636,7 +2644,7 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev,
		goto err_mr;

	teardown_driver(ndev);
	mlx5_vdpa_destroy_mr(mvdev);
	mlx5_vdpa_destroy_mr_asid(mvdev, asid);
	err = mlx5_vdpa_create_mr(mvdev, iotlb, asid);
	if (err)
		goto err_mr;
@@ -2652,7 +2660,7 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev,
	return 0;

err_setup:
	mlx5_vdpa_destroy_mr(mvdev);
	mlx5_vdpa_destroy_mr_asid(mvdev, asid);
err_mr:
	return err;
}
@@ -3548,17 +3556,6 @@ static void mlx5v_remove(struct auxiliary_device *adev)
	kfree(mgtdev);
}

static void mlx5v_shutdown(struct auxiliary_device *auxdev)
{
	struct mlx5_vdpa_mgmtdev *mgtdev;
	struct mlx5_vdpa_net *ndev;

	mgtdev = auxiliary_get_drvdata(auxdev);
	ndev = mgtdev->ndev;

	free_irqs(ndev);
}

static const struct auxiliary_device_id mlx5v_id_table[] = {
	{ .name = MLX5_ADEV_NAME ".vnet", },
	{},
@@ -3570,7 +3567,6 @@ static struct auxiliary_driver mlx5v_driver = {
	.name = "vnet",
	.probe = mlx5v_probe,
	.remove = mlx5v_remove,
	.shutdown = mlx5v_shutdown,
	.id_table = mlx5v_id_table,
};

Loading