Commit 7fa005ca authored by Max Gurtovoy's avatar Max Gurtovoy Committed by Alex Williamson
Browse files

vfio/pci: Introduce vfio_pci_core.ko



Now that vfio_pci has been split into two source modules, one focusing on
the "struct pci_driver" (vfio_pci.c) and a toolbox library of code
(vfio_pci_core.c), complete the split and move them into two different
kernel modules.

As before vfio_pci.ko continues to present the same interface under sysfs
and this change will have no functional impact.

Splitting into another module and adding exports allows creating new HW
specific VFIO PCI drivers that can implement device specific
functionality, such as VFIO migration interfaces or specialized device
requirements.

Signed-off-by: default avatarMax Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarYishai Hadas <yishaih@nvidia.com>
Link: https://lore.kernel.org/r/20210826103912.128972-14-yishaih@nvidia.com


Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 85c94dcf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19466,6 +19466,7 @@ T: git git://github.com/awilliam/linux-vfio.git
F:	Documentation/driver-api/vfio.rst
F:	drivers/vfio/
F:	include/linux/vfio.h
F:	include/linux/vfio_pci_core.h
F:	include/uapi/linux/vfio.h
VFIO FSL-MC DRIVER
+18 −15
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only
config VFIO_PCI
	tristate "VFIO support for PCI devices"
	depends on PCI
	depends on MMU
if PCI && MMU
config VFIO_PCI_CORE
	tristate
	select VFIO_VIRQFD
	select IRQ_BYPASS_MANAGER

config VFIO_PCI_MMAP
	def_bool y if !S390

config VFIO_PCI_INTX
	def_bool y if !S390

config VFIO_PCI
	tristate "Generic VFIO support for any PCI device"
	select VFIO_PCI_CORE
	help
	  Support for the PCI VFIO bus driver.  This is required to make
	  use of PCI drivers using the VFIO framework.
	  Support for the generic PCI VFIO bus driver which can connect any
	  PCI device to the VFIO framework.

	  If you don't know what to do here, say N.

if VFIO_PCI
config VFIO_PCI_VGA
	bool "VFIO PCI support for VGA devices"
	bool "Generic VFIO PCI support for VGA devices"
	depends on X86 && VGA_ARB
	help
	  Support for VGA extension to VFIO PCI.  This exposes an additional
@@ -22,14 +31,8 @@ config VFIO_PCI_VGA

	  If you don't know what to do here, say N.

config VFIO_PCI_MMAP
	def_bool y if !S390

config VFIO_PCI_INTX
	def_bool y if !S390

config VFIO_PCI_IGD
	bool "VFIO PCI extensions for Intel graphics (GVT-d)"
	bool "Generic VFIO PCI extensions for Intel graphics (GVT-d)"
	depends on X86
	default y
	help
@@ -39,5 +42,5 @@ config VFIO_PCI_IGD
	  and LPC bridge config space.

	  To enable Intel IGD assignment through vfio-pci, say Y.

endif
endif
+5 −3
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only

vfio-pci-y := vfio_pci.o vfio_pci_core.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio_pci_config.o
vfio-pci-$(CONFIG_VFIO_PCI_IGD) += vfio_pci_igd.o
vfio-pci-$(CONFIG_S390) += vfio_pci_zdev.o
vfio-pci-core-y := vfio_pci_core.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio_pci_config.o
vfio-pci-core-$(CONFIG_S390) += vfio_pci_zdev.o
obj-$(CONFIG_VFIO_PCI_CORE) += vfio-pci-core.o

vfio-pci-y := vfio_pci.o
vfio-pci-$(CONFIG_VFIO_PCI_IGD) += vfio_pci_igd.o
obj-$(CONFIG_VFIO_PCI) += vfio-pci.o
+3 −11
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
#include <linux/types.h>
#include <linux/uaccess.h>

#include "vfio_pci_core.h"
#include <linux/vfio_pci_core.h>

#define DRIVER_AUTHOR   "Alex Williamson <alex.williamson@redhat.com>"
#define DRIVER_DESC     "VFIO PCI - User Level meta-driver"
@@ -153,6 +153,7 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
	ret = vfio_pci_core_register_device(vdev);
	if (ret)
		goto out_free;
	dev_set_drvdata(&pdev->dev, vdev);
	return 0;

out_free:
@@ -246,14 +247,10 @@ static int __init vfio_pci_init(void)

	vfio_pci_core_set_params(nointxmask, is_disable_vga, disable_idle_d3);

	ret = vfio_pci_core_init();
	if (ret)
		return ret;

	/* Register and scan for devices */
	ret = pci_register_driver(&vfio_pci_driver);
	if (ret)
		goto out;
		return ret;

	vfio_pci_fill_ids();

@@ -261,17 +258,12 @@ static int __init vfio_pci_init(void)
		pr_warn("device denylist disabled.\n");

	return 0;

out:
	vfio_pci_core_cleanup();
	return ret;
}
module_init(vfio_pci_init);

static void __exit vfio_pci_cleanup(void)
{
	pci_unregister_driver(&vfio_pci_driver);
	vfio_pci_core_cleanup();
}
module_exit(vfio_pci_cleanup);

+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
#include <linux/vfio.h>
#include <linux/slab.h>

#include "vfio_pci_core.h"
#include <linux/vfio_pci_core.h>

/* Fake capability ID for standard config space */
#define PCI_CAP_ID_BASIC	0
Loading