Skip to content

Commit c38ff5b

Browse files
jgunthorpeawilliam
authored andcommitted
vfio: Remove vfio_external_group_match_file()
vfio_group_fops_open() ensures there is only ever one struct file open for any struct vfio_group at any time: /* Do we need multiple instances of the group open? Seems not. */ opened = atomic_cmpxchg(&group->opened, 0, 1); if (opened) { vfio_group_put(group); return -EBUSY; Therefor the struct file * can be used directly to search the list of VFIO groups that KVM keeps instead of using the vfio_external_group_match_file() callback to try to figure out if the passed in FD matches the list or not. Delete vfio_external_group_match_file(). Reviewed-by: Kevin Tian <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Yi Liu <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent 50d63b5 commit c38ff5b

File tree

3 files changed

+1
-29
lines changed

3 files changed

+1
-29
lines changed

drivers/vfio/vfio.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,15 +1685,6 @@ void vfio_group_put_external_user(struct vfio_group *group)
16851685
}
16861686
EXPORT_SYMBOL_GPL(vfio_group_put_external_user);
16871687

1688-
bool vfio_external_group_match_file(struct vfio_group *test_group,
1689-
struct file *filep)
1690-
{
1691-
struct vfio_group *group = filep->private_data;
1692-
1693-
return (filep->f_op == &vfio_group_fops) && (group == test_group);
1694-
}
1695-
EXPORT_SYMBOL_GPL(vfio_external_group_match_file);
1696-
16971688
/**
16981689
* vfio_file_iommu_group - Return the struct iommu_group for the vfio group file
16991690
* @file: VFIO group file

include/linux/vfio.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ int vfio_mig_get_next_state(struct vfio_device *device,
138138
*/
139139
extern struct vfio_group *vfio_group_get_external_user(struct file *filep);
140140
extern void vfio_group_put_external_user(struct vfio_group *group);
141-
extern bool vfio_external_group_match_file(struct vfio_group *group,
142-
struct file *filep);
143141
extern struct iommu_group *vfio_file_iommu_group(struct file *file);
144142
extern long vfio_external_check_extension(struct vfio_group *group,
145143
unsigned long arg);

virt/kvm/vfio.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,6 @@ static struct vfio_group *kvm_vfio_group_get_external_user(struct file *filep)
4949
return vfio_group;
5050
}
5151

52-
static bool kvm_vfio_external_group_match_file(struct vfio_group *group,
53-
struct file *filep)
54-
{
55-
bool ret, (*fn)(struct vfio_group *, struct file *);
56-
57-
fn = symbol_get(vfio_external_group_match_file);
58-
if (!fn)
59-
return false;
60-
61-
ret = fn(group, filep);
62-
63-
symbol_put(vfio_external_group_match_file);
64-
65-
return ret;
66-
}
67-
6852
static void kvm_vfio_group_put_external_user(struct vfio_group *vfio_group)
6953
{
7054
void (*fn)(struct vfio_group *);
@@ -239,8 +223,7 @@ static int kvm_vfio_group_del(struct kvm_device *dev, unsigned int fd)
239223
mutex_lock(&kv->lock);
240224

241225
list_for_each_entry(kvg, &kv->group_list, node) {
242-
if (!kvm_vfio_external_group_match_file(kvg->vfio_group,
243-
f.file))
226+
if (kvg->file != f.file)
244227
continue;
245228

246229
list_del(&kvg->node);

0 commit comments

Comments
 (0)