From: jiangdongxu jiangdongxu1@huawei.com
virt inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8TP8X
----------------------------------------------------------------------
When we call vhost_vdpa_reset, vdpa device pci driver may request irq, at this time, wo have not init msi iova for device, may cause an error, call vhost_vdpa_alloc_domain first to avoid this scene.
Signed-off-by: jiangdongxu jiangdongxu1@huawei.com --- drivers/vhost/vdpa.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index ac92c0364b2c..deea79d4920a 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -1490,6 +1490,9 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) opened = atomic_cmpxchg(&v->opened, 0, 1); if (opened) return -EBUSY; + r = vhost_vdpa_alloc_domain(v); + if (r) + return r;
nvqs = v->nvqs; r = vhost_vdpa_reset(v); @@ -1510,19 +1513,14 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) vhost_dev_init(dev, vqs, nvqs, 0, 0, 0, false, vhost_vdpa_process_iotlb_msg);
- r = vhost_vdpa_alloc_domain(v); - if (r) - goto err_alloc_domain; - vhost_vdpa_set_iova_range(v);
filep->private_data = v;
return 0;
-err_alloc_domain: - vhost_vdpa_cleanup(v); err: + vhost_vdpa_free_domain(v); atomic_dec(&v->opened); return r; } @@ -1548,7 +1546,6 @@ static int vhost_vdpa_release(struct inode *inode, struct file *filep) vhost_vdpa_unbind_mm(v); vhost_vdpa_config_put(v); vhost_vdpa_cleanup(v); - vhost_iotlb_reset(&v->resv_iotlb); mutex_unlock(&d->mutex);
atomic_dec(&v->opened);