Commit ae16bb6a authored by jiangdongxu's avatar jiangdongxu Committed by Jiang Dongxu
Browse files

vhost-vdpa: add reset state params to indicate reset level

virt inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I86ITO



----------------------------------------------------------------------

When vdpa hardware is used, some hardware initialization may be
required. Currently, qemu connects to vdpa devices through the vhost
framework. Since qemu opens the vhost device, the vdpa device cannot
sense the action of qemu opening, which may cause the hardware status to
be incorrect.

Add the interface parameter state to the vdpa reset interface, which
respectively identifies the reset when the device is turned on/off
and the virtio reset issued by the virtual machine.

Signed-off-by: default avatarjiangdongxu <jiangdongxu1@huawei.com>
parent c4c6d735
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -233,7 +233,7 @@ static void ifcvf_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status)
	ifcvf_set_status(vf, status);
}

static int ifcvf_vdpa_reset(struct vdpa_device *vdpa_dev)
static int ifcvf_vdpa_reset(struct vdpa_device *vdpa_dev, int state)
{
	struct ifcvf_adapter *adapter;
	struct ifcvf_hw *vf;
+1 −1
Original line number Diff line number Diff line
@@ -1800,7 +1800,7 @@ static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status)
	ndev->mvdev.status |= VIRTIO_CONFIG_S_FAILED;
}

static int mlx5_vdpa_reset(struct vdpa_device *vdev)
static int mlx5_vdpa_reset(struct vdpa_device *vdev, int state)
{
	struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
	struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
+1 −1
Original line number Diff line number Diff line
@@ -454,7 +454,7 @@ static void vdpasim_set_status(struct vdpa_device *vdpa, u8 status)
	spin_unlock(&vdpasim->lock);
}

static int vdpasim_reset(struct vdpa_device *vdpa)
static int vdpasim_reset(struct vdpa_device *vdpa, int state)
{
	struct vdpasim *vdpasim = vdpa_to_sim(vdpa);

+1 −1
Original line number Diff line number Diff line
@@ -220,7 +220,7 @@ static void vp_vdpa_set_status(struct vdpa_device *vdpa, u8 status)
	vp_modern_set_status(mdev, status);
}

static int vp_vdpa_reset(struct vdpa_device *vdpa)
static int vp_vdpa_reset(struct vdpa_device *vdpa, int state)
{
	struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
	struct virtio_pci_modern_device *mdev = vp_vdpa_to_mdev(vp_vdpa);
+5 −5
Original line number Diff line number Diff line
@@ -212,13 +212,13 @@ static void vhost_vdpa_unsetup_vq_irq(struct vhost_vdpa *v, u16 qid)
	irq_bypass_unregister_producer(&vq->call_ctx.producer);
}

static int vhost_vdpa_reset(struct vhost_vdpa *v)
static int vhost_vdpa_reset(struct vhost_vdpa *v, int state)
{
	struct vdpa_device *vdpa = v->vdpa;

	v->in_batch = 0;

	return vdpa_reset(vdpa);
	return vdpa_reset(vdpa, state);
}

static long vhost_vdpa_bind_mm(struct vhost_vdpa *v)
@@ -297,7 +297,7 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
			vhost_vdpa_unsetup_vq_irq(v, i);

	if (status == 0) {
		ret = vdpa_reset(vdpa);
		ret = vdpa_reset(vdpa, VDPA_DEV_RESET_VIRTIO);
		if (ret)
			return ret;
	} else
@@ -1496,7 +1496,7 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
		return r;

	nvqs = v->nvqs;
	r = vhost_vdpa_reset(v);
	r = vhost_vdpa_reset(v, VDPA_DEV_RESET_OPEN);
	if (r)
		goto err;

@@ -1542,7 +1542,7 @@ static int vhost_vdpa_release(struct inode *inode, struct file *filep)
	mutex_lock(&d->mutex);
	filep->private_data = NULL;
	vhost_vdpa_clean_irq(v);
	vhost_vdpa_reset(v);
	vhost_vdpa_reset(v, VDPA_DEV_RESET_CLOSE);
	vhost_dev_stop(&v->vdev);
	vhost_vdpa_unbind_mm(v);
	vhost_vdpa_config_put(v);
Loading