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
39 struct vhost_virtqueue *vqs;39 struct vhost_virtqueue *vqs;
40 struct completion completion;40 struct completion completion;
41 struct vdpa_device *vdpa;41 struct vdpa_device *vdpa;
42 struct vhost_iotlb *iotlb;
42 struct device dev;43 struct device dev;
43 struct cdev cdev;44 struct cdev cdev;
44 atomic_t opened;45 atomic_t opened;
@@ -589,12 +590,11 @@ static void vhost_vdpa_iotlb_unmap(struct vhost_vdpa *v, · 544 unmodified lines
589 590
590static void vhost_vdpa_iotlb_free(struct vhost_vdpa *v)591static void vhost_vdpa_iotlb_free(struct vhost_vdpa *v)
591{592{
592 struct vhost_dev *dev = &v->vdev;593 struct vhost_iotlb *iotlb = v->iotlb;
593 struct vhost_iotlb *iotlb = dev->iotlb;
594 594
595 vhost_vdpa_iotlb_unmap(v, iotlb, 0ULL, 0ULL - 1);595 vhost_vdpa_iotlb_unmap(v, iotlb, 0ULL, 0ULL - 1);
596 kfree(dev->iotlb);596 kfree(v->iotlb);
597 dev->iotlb = NULL;597 v->iotlb = NULL;
598}598}
599 599
600static int perm_to_iommu_flags(u32 perm)600static 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
876 struct vhost_vdpa *v = container_of(dev, struct vhost_vdpa, vdev);876 struct vhost_vdpa *v = container_of(dev, struct vhost_vdpa, vdev);
877 struct vdpa_device *vdpa = v->vdpa;877 struct vdpa_device *vdpa = v->vdpa;
878 const struct vdpa_config_ops *ops = vdpa->config;878 const struct vdpa_config_ops *ops = vdpa->config;
879 struct vhost_iotlb *iotlb = dev->iotlb;879 struct vhost_iotlb *iotlb = v->iotlb;
880 int r = 0;880 int r = 0;
881 881
882 mutex_lock(&dev->mutex);882 mutex_lock(&dev->mutex);
@@ -1017,15 +1017,15 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) · 134 unmodified lines
1017 vhost_dev_init(dev, vqs, nvqs, 0, 0, 0, false,1017 vhost_dev_init(dev, vqs, nvqs, 0, 0, 0, false,
1018 vhost_vdpa_process_iotlb_msg);1018 vhost_vdpa_process_iotlb_msg);
1019 1019
1020 dev->iotlb = vhost_iotlb_alloc(0, 0);1020 v->iotlb = vhost_iotlb_alloc(0, 0);
1021 if (!dev->iotlb) {1021 if (!v->iotlb) {
1022 r = -ENOMEM;1022 r = -ENOMEM;
1023 goto err_init_iotlb;1023 goto err_init_iotlb;
1024 }1024 }
1025 1025
1026 r = vhost_vdpa_alloc_domain(v);1026 r = vhost_vdpa_alloc_domain(v);
1027 if (r)1027 if (r)
1028 goto err_init_iotlb;1028 goto err_alloc_domain;
1029 1029
1030 vhost_vdpa_set_iova_range(v);1030 vhost_vdpa_set_iova_range(v);
1031 1031
@@ -1033,6 +1033,8 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) · 1 unmodified line
1033 1033
1034 return 0;1034 return 0;
1035 1035
1036err_alloc_domain:
1037 vhost_vdpa_iotlb_free(v);
1036err_init_iotlb:1038err_init_iotlb:
1037 vhost_dev_cleanup(&v->vdev);1039 vhost_dev_cleanup(&v->vdev);
1038 kfree(vqs);1040 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