Skip to content

Commit 231657b

Browse files
jgunthorpeAlex Williamson
authored andcommitted
vfio: Remove dead code
Now that callers have been updated to use the vfio_device APIs the driver facing group interface is no longer used, delete it: - vfio_group_get_external_user_from_dev() - vfio_group_pin_pages() - vfio_group_unpin_pages() - vfio_group_iommu_domain() -- Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/6-v4-8045e76bf00b+13d-vfio_mdev_no_group_jgg@nvidia.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 5eb20a7 commit 231657b

2 files changed

Lines changed: 0 additions & 162 deletions

File tree

drivers/vfio/vfio.c

Lines changed: 0 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,44 +1947,6 @@ struct vfio_group *vfio_group_get_external_user(struct file *filep)
19471947
}
19481948
EXPORT_SYMBOL_GPL(vfio_group_get_external_user);
19491949

1950-
/*
1951-
* External user API, exported by symbols to be linked dynamically.
1952-
* The external user passes in a device pointer
1953-
* to verify that:
1954-
* - A VFIO group is assiciated with the device;
1955-
* - IOMMU is set for the group.
1956-
* If both checks passed, vfio_group_get_external_user_from_dev()
1957-
* increments the container user counter to prevent the VFIO group
1958-
* from disposal before external user exits and returns the pointer
1959-
* to the VFIO group.
1960-
*
1961-
* When the external user finishes using the VFIO group, it calls
1962-
* vfio_group_put_external_user() to release the VFIO group and
1963-
* decrement the container user counter.
1964-
*
1965-
* @dev [in] : device
1966-
* Return error PTR or pointer to VFIO group.
1967-
*/
1968-
1969-
struct vfio_group *vfio_group_get_external_user_from_dev(struct device *dev)
1970-
{
1971-
struct vfio_group *group;
1972-
int ret;
1973-
1974-
group = vfio_group_get_from_dev(dev);
1975-
if (!group)
1976-
return ERR_PTR(-ENODEV);
1977-
1978-
ret = vfio_group_add_container_user(group);
1979-
if (ret) {
1980-
vfio_group_put(group);
1981-
return ERR_PTR(ret);
1982-
}
1983-
1984-
return group;
1985-
}
1986-
EXPORT_SYMBOL_GPL(vfio_group_get_external_user_from_dev);
1987-
19881950
void vfio_group_put_external_user(struct vfio_group *group)
19891951
{
19901952
vfio_group_try_dissolve_container(group);
@@ -2218,101 +2180,6 @@ int vfio_unpin_pages(struct vfio_device *device, unsigned long *user_pfn,
22182180
}
22192181
EXPORT_SYMBOL(vfio_unpin_pages);
22202182

2221-
/*
2222-
* Pin a set of guest IOVA PFNs and return their associated host PFNs for a
2223-
* VFIO group.
2224-
*
2225-
* The caller needs to call vfio_group_get_external_user() or
2226-
* vfio_group_get_external_user_from_dev() prior to calling this interface,
2227-
* so as to prevent the VFIO group from disposal in the middle of the call.
2228-
* But it can keep the reference to the VFIO group for several calls into
2229-
* this interface.
2230-
* After finishing using of the VFIO group, the caller needs to release the
2231-
* VFIO group by calling vfio_group_put_external_user().
2232-
*
2233-
* @group [in] : VFIO group
2234-
* @user_iova_pfn [in] : array of user/guest IOVA PFNs to be pinned.
2235-
* @npage [in] : count of elements in user_iova_pfn array.
2236-
* This count should not be greater
2237-
* VFIO_PIN_PAGES_MAX_ENTRIES.
2238-
* @prot [in] : protection flags
2239-
* @phys_pfn [out] : array of host PFNs
2240-
* Return error or number of pages pinned.
2241-
*/
2242-
int vfio_group_pin_pages(struct vfio_group *group,
2243-
unsigned long *user_iova_pfn, int npage,
2244-
int prot, unsigned long *phys_pfn)
2245-
{
2246-
struct vfio_container *container;
2247-
struct vfio_iommu_driver *driver;
2248-
int ret;
2249-
2250-
if (!group || !user_iova_pfn || !phys_pfn || !npage)
2251-
return -EINVAL;
2252-
2253-
if (group->dev_counter > 1)
2254-
return -EINVAL;
2255-
2256-
if (npage > VFIO_PIN_PAGES_MAX_ENTRIES)
2257-
return -E2BIG;
2258-
2259-
container = group->container;
2260-
driver = container->iommu_driver;
2261-
if (likely(driver && driver->ops->pin_pages))
2262-
ret = driver->ops->pin_pages(container->iommu_data,
2263-
group->iommu_group, user_iova_pfn,
2264-
npage, prot, phys_pfn);
2265-
else
2266-
ret = -ENOTTY;
2267-
2268-
return ret;
2269-
}
2270-
EXPORT_SYMBOL(vfio_group_pin_pages);
2271-
2272-
/*
2273-
* Unpin a set of guest IOVA PFNs for a VFIO group.
2274-
*
2275-
* The caller needs to call vfio_group_get_external_user() or
2276-
* vfio_group_get_external_user_from_dev() prior to calling this interface,
2277-
* so as to prevent the VFIO group from disposal in the middle of the call.
2278-
* But it can keep the reference to the VFIO group for several calls into
2279-
* this interface.
2280-
* After finishing using of the VFIO group, the caller needs to release the
2281-
* VFIO group by calling vfio_group_put_external_user().
2282-
*
2283-
* @group [in] : vfio group
2284-
* @user_iova_pfn [in] : array of user/guest IOVA PFNs to be unpinned.
2285-
* @npage [in] : count of elements in user_iova_pfn array.
2286-
* This count should not be greater than
2287-
* VFIO_PIN_PAGES_MAX_ENTRIES.
2288-
* Return error or number of pages unpinned.
2289-
*/
2290-
int vfio_group_unpin_pages(struct vfio_group *group,
2291-
unsigned long *user_iova_pfn, int npage)
2292-
{
2293-
struct vfio_container *container;
2294-
struct vfio_iommu_driver *driver;
2295-
int ret;
2296-
2297-
if (!group || !user_iova_pfn || !npage)
2298-
return -EINVAL;
2299-
2300-
if (npage > VFIO_PIN_PAGES_MAX_ENTRIES)
2301-
return -E2BIG;
2302-
2303-
container = group->container;
2304-
driver = container->iommu_driver;
2305-
if (likely(driver && driver->ops->unpin_pages))
2306-
ret = driver->ops->unpin_pages(container->iommu_data,
2307-
user_iova_pfn, npage);
2308-
else
2309-
ret = -ENOTTY;
2310-
2311-
return ret;
2312-
}
2313-
EXPORT_SYMBOL(vfio_group_unpin_pages);
2314-
2315-
23162183
/*
23172184
* This interface allows the CPUs to perform some sort of virtual DMA on
23182185
* behalf of the device.
@@ -2516,24 +2383,6 @@ int vfio_unregister_notifier(struct vfio_device *device,
25162383
}
25172384
EXPORT_SYMBOL(vfio_unregister_notifier);
25182385

2519-
struct iommu_domain *vfio_group_iommu_domain(struct vfio_group *group)
2520-
{
2521-
struct vfio_container *container;
2522-
struct vfio_iommu_driver *driver;
2523-
2524-
if (!group)
2525-
return ERR_PTR(-EINVAL);
2526-
2527-
container = group->container;
2528-
driver = container->iommu_driver;
2529-
if (likely(driver && driver->ops->group_iommu_domain))
2530-
return driver->ops->group_iommu_domain(container->iommu_data,
2531-
group->iommu_group);
2532-
2533-
return ERR_PTR(-ENOTTY);
2534-
}
2535-
EXPORT_SYMBOL_GPL(vfio_group_iommu_domain);
2536-
25372386
/*
25382387
* Module/class support
25392388
*/

include/linux/vfio.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ int vfio_mig_get_next_state(struct vfio_device *device,
140140
*/
141141
extern struct vfio_group *vfio_group_get_external_user(struct file *filep);
142142
extern void vfio_group_put_external_user(struct vfio_group *group);
143-
extern struct vfio_group *vfio_group_get_external_user_from_dev(struct device
144-
*dev);
145143
extern bool vfio_external_group_match_file(struct vfio_group *group,
146144
struct file *filep);
147145
extern int vfio_external_user_iommu_id(struct vfio_group *group);
@@ -154,18 +152,9 @@ extern int vfio_pin_pages(struct vfio_device *device, unsigned long *user_pfn,
154152
int npage, int prot, unsigned long *phys_pfn);
155153
extern int vfio_unpin_pages(struct vfio_device *device, unsigned long *user_pfn,
156154
int npage);
157-
158-
extern int vfio_group_pin_pages(struct vfio_group *group,
159-
unsigned long *user_iova_pfn, int npage,
160-
int prot, unsigned long *phys_pfn);
161-
extern int vfio_group_unpin_pages(struct vfio_group *group,
162-
unsigned long *user_iova_pfn, int npage);
163-
164155
extern int vfio_dma_rw(struct vfio_device *device, dma_addr_t user_iova,
165156
void *data, size_t len, bool write);
166157

167-
extern struct iommu_domain *vfio_group_iommu_domain(struct vfio_group *group);
168-
169158
/* each type has independent events */
170159
enum vfio_notify_type {
171160
VFIO_IOMMU_NOTIFY = 0,

0 commit comments

Comments
 (0)