Skip to content

Commit 8c9c727

Browse files
jpemartinsjgunthorpe
authored andcommitted
vfio: Move iova_bitmap into iommufd
Both VFIO and IOMMUFD will need iova bitmap for storing dirties and walking the user bitmaps, so move to the common dependency into IOMMUFD. In doing so, create the symbol IOMMUFD_DRIVER which designates the builtin code that will be used by drivers when selected. Today this means MLX5_VFIO_PCI and PDS_VFIO_PCI. IOMMU drivers will do the same (in future patches) when supporting dirty tracking and select IOMMUFD_DRIVER accordingly. Given that the symbol maybe be disabled, add header definitions in iova_bitmap.h for when IOMMUFD_DRIVER=n Link: https://lore.kernel.org/r/20231024135109.73787-3-joao.m.martins@oracle.com Signed-off-by: Joao Martins <joao.m.martins@oracle.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Brett Creeley <brett.creeley@amd.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 53f0b02 commit 8c9c727

7 files changed

Lines changed: 34 additions & 2 deletions

File tree

drivers/iommu/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ config IOMMU_IOVA
77
config IOMMU_API
88
bool
99

10+
config IOMMUFD_DRIVER
11+
bool
12+
default n
13+
1014
menuconfig IOMMU_SUPPORT
1115
bool "IOMMU Hardware Support"
1216
depends on MMU

drivers/iommu/iommufd/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ iommufd-y := \
1111
iommufd-$(CONFIG_IOMMUFD_TEST) += selftest.o
1212

1313
obj-$(CONFIG_IOMMUFD) += iommufd.o
14+
obj-$(CONFIG_IOMMUFD_DRIVER) += iova_bitmap.o

drivers/vfio/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_VFIO) += vfio.o
33

4-
vfio-y += vfio_main.o \
5-
iova_bitmap.o
4+
vfio-y += vfio_main.o
65
vfio-$(CONFIG_VFIO_DEVICE_CDEV) += device_cdev.o
76
vfio-$(CONFIG_VFIO_GROUP) += group.o
87
vfio-$(CONFIG_IOMMUFD) += iommufd.o

drivers/vfio/pci/mlx5/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ config MLX5_VFIO_PCI
33
tristate "VFIO support for MLX5 PCI devices"
44
depends on MLX5_CORE
55
select VFIO_PCI_CORE
6+
select IOMMUFD_DRIVER
67
help
78
This provides migration support for MLX5 devices using the VFIO
89
framework.

drivers/vfio/pci/pds/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ config PDS_VFIO_PCI
55
tristate "VFIO support for PDS PCI devices"
66
depends on PDS_CORE
77
select VFIO_PCI_CORE
8+
select IOMMUFD_DRIVER
89
help
910
This provides generic PCI support for PDS devices using the VFIO
1011
framework.

include/linux/iova_bitmap.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
#define _IOVA_BITMAP_H_
88

99
#include <linux/types.h>
10+
#include <linux/errno.h>
1011

1112
struct iova_bitmap;
1213

1314
typedef int (*iova_bitmap_fn_t)(struct iova_bitmap *bitmap,
1415
unsigned long iova, size_t length,
1516
void *opaque);
1617

18+
#if IS_ENABLED(CONFIG_IOMMUFD_DRIVER)
1719
struct iova_bitmap *iova_bitmap_alloc(unsigned long iova, size_t length,
1820
unsigned long page_size,
1921
u64 __user *data);
@@ -22,5 +24,29 @@ int iova_bitmap_for_each(struct iova_bitmap *bitmap, void *opaque,
2224
iova_bitmap_fn_t fn);
2325
void iova_bitmap_set(struct iova_bitmap *bitmap,
2426
unsigned long iova, size_t length);
27+
#else
28+
static inline struct iova_bitmap *iova_bitmap_alloc(unsigned long iova,
29+
size_t length,
30+
unsigned long page_size,
31+
u64 __user *data)
32+
{
33+
return NULL;
34+
}
35+
36+
static inline void iova_bitmap_free(struct iova_bitmap *bitmap)
37+
{
38+
}
39+
40+
static inline int iova_bitmap_for_each(struct iova_bitmap *bitmap, void *opaque,
41+
iova_bitmap_fn_t fn)
42+
{
43+
return -EOPNOTSUPP;
44+
}
45+
46+
static inline void iova_bitmap_set(struct iova_bitmap *bitmap,
47+
unsigned long iova, size_t length)
48+
{
49+
}
50+
#endif
2551

2652
#endif

0 commit comments

Comments
 (0)