aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2021-09-30 14:26:28 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2021-09-30 14:26:28 +1000
commit4efd9b239741ad40581945cb6bd8e8fa12e1800e (patch)
tree8b4338da65d9736385231f02fcfb231b9cea7f96
parentd650f2f79d72fa946fd2e6076a53906ffced931e (diff)
parentdd7dc7e82b147c2424c446681a8ed46d78bd9b98 (diff)
downloaddevel-4efd9b239741ad40581945cb6bd8e8fa12e1800e.tar.gz
Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git
-rw-r--r--drivers/vdpa/vdpa_user/vduse_dev.c8
-rw-r--r--drivers/vhost/vdpa.c8
2 files changed, 12 insertions, 4 deletions
diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index 26e3d90d1e7c94..cefb301b2ee48a 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -966,6 +966,10 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
break;
}
case VDUSE_DEV_INJECT_CONFIG_IRQ:
+ ret = -EINVAL;
+ if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
+ break;
+
ret = 0;
queue_work(vduse_irq_wq, &dev->inject);
break;
@@ -1045,6 +1049,10 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
case VDUSE_VQ_INJECT_IRQ: {
u32 index;
+ ret = -EINVAL;
+ if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
+ break;
+
ret = -EFAULT;
if (get_user(index, (u32 __user *)argp))
break;
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 35927ceb26ff32..924751427cd2ad 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -173,6 +173,10 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
if (status != 0 && (ops->get_status(vdpa) & ~status) != 0)
return -EINVAL;
+ if ((status_old & VIRTIO_CONFIG_S_DRIVER_OK) && !(status & VIRTIO_CONFIG_S_DRIVER_OK))
+ for (i = 0; i < nvqs; i++)
+ vhost_vdpa_unsetup_vq_irq(v, i);
+
if (status == 0) {
ret = ops->reset(vdpa);
if (ret)
@@ -184,10 +188,6 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
for (i = 0; i < nvqs; i++)
vhost_vdpa_setup_vq_irq(v, i);
- if ((status_old & VIRTIO_CONFIG_S_DRIVER_OK) && !(status & VIRTIO_CONFIG_S_DRIVER_OK))
- for (i = 0; i < nvqs; i++)
- vhost_vdpa_unsetup_vq_irq(v, i);
-
return 0;
}