mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
Allow pciback to be built as a module.
From: Jan Beulich Signed-off-by: Keir Fraser <keir@xensource.com>
This commit is contained in:
1 parent
b1d3128dd8
commit
db4d5fc53b
7 files changed
+45
-30
No files matched your search
@@ -30,9 +30,9 @@ config XEN_UNPRIVILEGED_GUEST
|
||||
default !XEN_PRIVILEGED_GUEST
|
||||
|
||||
config XEN_PCIDEV_BACKEND
|
||||
bool "PCI device backend driver"
|
||||
select PCI
|
||||
default y if XEN_PRIVILEGED_GUEST
|
||||
tristate "PCI device backend driver"
|
||||
depends PCI
|
||||
default XEN_PRIVILEGED_GUEST
|
||||
help
|
||||
The PCI device backend driver allows the kernel to export arbitrary
|
||||
PCI devices to other guests.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
obj-y += pciback.o
|
||||
obj-$(CONFIG_XEN_PCIDEV_BACKEND) += pciback.o
|
||||
|
||||
pciback-y := pci_stub.o pciback_ops.o xenbus.o
|
||||
pciback-y += conf_space.o conf_space_header.o
|
||||
pciback-${CONFIG_XEN_PCIDEV_BACKEND_VPCI} += vpci.o
|
||||
pciback-${CONFIG_XEN_PCIDEV_BACKEND_PASS} += passthrough.o
|
||||
pciback-$(CONFIG_XEN_PCIDEV_BACKEND_VPCI) += vpci.o
|
||||
pciback-$(CONFIG_XEN_PCIDEV_BACKEND_PASS) += passthrough.o
|
||||
|
||||
ifeq ($(CONFIG_XEN_PCIDEV_BE_DEBUG),y)
|
||||
EXTRA_CFLAGS += -DDEBUG
|
||||
|
||||
@@ -24,21 +24,19 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)
|
||||
if (unlikely(verbose_request))
|
||||
printk(KERN_DEBUG "pciback: %s: enable\n",
|
||||
pci_name(dev));
|
||||
dev->is_enabled = 1;
|
||||
pcibios_enable_device(dev, (1 << PCI_NUM_RESOURCES) - 1);
|
||||
pci_enable_device(dev);
|
||||
} else if (dev->is_enabled && !is_enable_cmd(value)) {
|
||||
if (unlikely(verbose_request))
|
||||
printk(KERN_DEBUG "pciback: %s: disable\n",
|
||||
pci_name(dev));
|
||||
pciback_disable_device(dev);
|
||||
pci_disable_device(dev);
|
||||
}
|
||||
|
||||
if (!dev->is_busmaster && is_master_cmd(value)) {
|
||||
if (unlikely(verbose_request))
|
||||
printk(KERN_DEBUG "pciback: %s: set bus master\n",
|
||||
pci_name(dev));
|
||||
dev->is_busmaster = 1;
|
||||
pcibios_set_master(dev);
|
||||
pci_set_master(dev);
|
||||
}
|
||||
|
||||
if (value & PCI_COMMAND_INVALIDATE) {
|
||||
|
||||
@@ -208,8 +208,6 @@ static int __init pcistub_init_devices_late(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
device_initcall(pcistub_init_devices_late);
|
||||
|
||||
static int __devinit pcistub_seize(struct pci_dev *dev)
|
||||
{
|
||||
struct pci_stub_device *psdev;
|
||||
@@ -367,6 +365,7 @@ static int __init pcistub_init(void)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#ifndef MODULE
|
||||
/*
|
||||
* fs_initcall happens before device_initcall
|
||||
* so pciback *should* get called first (b/c we
|
||||
@@ -375,3 +374,34 @@ static int __init pcistub_init(void)
|
||||
* driver to register)
|
||||
*/
|
||||
fs_initcall(pcistub_init);
|
||||
#endif
|
||||
|
||||
static int __init pciback_init(void)
|
||||
{
|
||||
#ifndef MODULE
|
||||
int err;
|
||||
|
||||
err = pcistub_init();
|
||||
if (err < 0)
|
||||
return err;
|
||||
#endif
|
||||
|
||||
if (list_empty(&pci_stub_device_ids))
|
||||
return -ENODEV;
|
||||
pcistub_init_devices_late();
|
||||
pciback_xenbus_register();
|
||||
|
||||
__unsafe(THIS_MODULE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pciback_cleanup(void)
|
||||
{
|
||||
BUG();
|
||||
}
|
||||
|
||||
module_init(pciback_init);
|
||||
module_exit(pciback_cleanup);
|
||||
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
@@ -43,7 +43,6 @@ struct pci_dev *pcistub_get_pci_dev(struct pci_dev *dev);
|
||||
void pcistub_put_pci_dev(struct pci_dev *dev);
|
||||
|
||||
/* Ensure a device is turned off or reset */
|
||||
void pciback_disable_device(struct pci_dev *dev);
|
||||
void pciback_reset_device(struct pci_dev *pdev);
|
||||
|
||||
/* Access a virtual configuration space for a PCI device */
|
||||
@@ -69,5 +68,7 @@ void pciback_release_devices(struct pciback_device *pdev);
|
||||
/* Handles events from front-end */
|
||||
irqreturn_t pciback_handle_event(int irq, void *dev_id, struct pt_regs *regs);
|
||||
|
||||
int pciback_xenbus_register(void);
|
||||
|
||||
extern int verbose_request;
|
||||
#endif
|
||||
@@ -10,17 +10,6 @@
|
||||
int verbose_request = 0;
|
||||
module_param(verbose_request, int, 0644);
|
||||
|
||||
/* For those architectures without a pcibios_disable_device */
|
||||
void __attribute__ ((weak)) pcibios_disable_device(struct pci_dev *dev) { }
|
||||
|
||||
void pciback_disable_device(struct pci_dev *dev)
|
||||
{
|
||||
if (dev->is_enabled) {
|
||||
dev->is_enabled = 0;
|
||||
pcibios_disable_device(dev);
|
||||
}
|
||||
}
|
||||
|
||||
/* Ensure a device is "turned off" and ready to be exported.
|
||||
* This also sets up the device's private data to keep track of what should
|
||||
* be in the base address registers (BARs) so that we can keep the
|
||||
@@ -32,7 +21,7 @@ void pciback_reset_device(struct pci_dev *dev)
|
||||
|
||||
/* Disable devices (but not bridges) */
|
||||
if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) {
|
||||
pciback_disable_device(dev);
|
||||
pci_disable_device(dev);
|
||||
|
||||
pci_write_config_word(dev, PCI_COMMAND, 0);
|
||||
|
||||
|
||||
@@ -430,10 +430,7 @@ static struct xenbus_driver xenbus_pciback_driver = {
|
||||
.otherend_changed = pciback_frontend_changed,
|
||||
};
|
||||
|
||||
static __init int pciback_xenbus_register(void)
|
||||
int __init pciback_xenbus_register(void)
|
||||
{
|
||||
return xenbus_register_backend(&xenbus_pciback_driver);
|
||||
}
|
||||
|
||||
/* Must only initialize our xenbus driver after the pcistub driver */
|
||||
device_initcall(pciback_xenbus_register);
|
||||