History

vhost-vdpa: switch to use vhost-vdpa specific IOTLB

To ease the implementation of per group ASID support for vDPA device. This patch switches to use a vhost-vdpa specific IOTLB to avoid the unnecessary refactoring of the vhost core.

Gautam Dawar committed 4 years ago

Commit 0b7ee471 parent ae967241 file · +10 −8Browse files

Unified · Split

drivers/vhost/vdpa.c+10−8
@@ -39,6 +39,7 @@ struct vhost_vdpa { · 38 unmodified lines
3939 struct vhost_virtqueue *vqs;
4040 struct completion completion;
4141 struct vdpa_device *vdpa;
42+ struct vhost_iotlb *iotlb;
4243 struct device dev;
4344 struct cdev cdev;
4445 atomic_t opened;
@@ -589,12 +590,11 @@ static void vhost_vdpa_iotlb_unmap(struct vhost_vdpa *v, · 544 unmodified lines
589590
590591 static void vhost_vdpa_iotlb_free(struct vhost_vdpa *v)
591592 {
592− struct vhost_dev *dev = &v->vdev;
593− struct vhost_iotlb *iotlb = dev->iotlb;
593+ struct vhost_iotlb *iotlb = v->iotlb;
594594
595595 vhost_vdpa_iotlb_unmap(v, iotlb, 0ULL, 0ULL - 1);
596− kfree(dev->iotlb);
597− dev->iotlb = NULL;
596+ kfree(v->iotlb);
597+ v->iotlb = NULL;
598598 }
599599
600600 static int perm_to_iommu_flags(u32 perm)
@@ -876,7 +876,7 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, · 275 unmodified lines
876876 struct vhost_vdpa *v = container_of(dev, struct vhost_vdpa, vdev);
877877 struct vdpa_device *vdpa = v->vdpa;
878878 const struct vdpa_config_ops *ops = vdpa->config;
879− struct vhost_iotlb *iotlb = dev->iotlb;
879+ struct vhost_iotlb *iotlb = v->iotlb;
880880 int r = 0;
881881
882882 mutex_lock(&dev->mutex);
@@ -1017,15 +1017,15 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) · 134 unmodified lines
10171017 vhost_dev_init(dev, vqs, nvqs, 0, 0, 0, false,
10181018 vhost_vdpa_process_iotlb_msg);
10191019
1020− dev->iotlb = vhost_iotlb_alloc(0, 0);
1021− if (!dev->iotlb) {
1020+ v->iotlb = vhost_iotlb_alloc(0, 0);
1021+ if (!v->iotlb) {
10221022 r = -ENOMEM;
10231023 goto err_init_iotlb;
10241024 }
10251025
10261026 r = vhost_vdpa_alloc_domain(v);
10271027 if (r)
1028− goto err_init_iotlb;
1028+ goto err_alloc_domain;
10291029
10301030 vhost_vdpa_set_iova_range(v);
10311031
@@ -1033,6 +1033,8 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) · 1 unmodified line
10331033
10341034 return 0;
10351035
1036+err_alloc_domain:
1037+ vhost_vdpa_iotlb_free(v);
10361038 err_init_iotlb:
10371039 vhost_dev_cleanup(&v->vdev);
10381040 kfree(vqs);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t