ia64/xen-unstable

changeset 9198:f527a18cc8c3

Allow pciback to be built as a module.

From: Jan Beulich
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Mar 08 18:41:12 2006 +0100 (2006-03-08)
parents 42a1f6ffd0e9
children 4af3f8bd7e0c
files linux-2.6-xen-sparse/drivers/xen/Kconfig linux-2.6-xen-sparse/drivers/xen/pciback/Makefile linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_header.c linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c linux-2.6-xen-sparse/drivers/xen/pciback/pciback.h linux-2.6-xen-sparse/drivers/xen/pciback/pciback_ops.c linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/Kconfig	Wed Mar 08 17:32:36 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig	Wed Mar 08 18:41:12 2006 +0100
     1.3 @@ -30,9 +30,9 @@ config XEN_UNPRIVILEGED_GUEST
     1.4  	default !XEN_PRIVILEGED_GUEST
     1.5  
     1.6  config XEN_PCIDEV_BACKEND
     1.7 -	bool "PCI device backend driver"
     1.8 -	select PCI
     1.9 -	default y if XEN_PRIVILEGED_GUEST
    1.10 +	tristate "PCI device backend driver"
    1.11 +	depends PCI
    1.12 +	default XEN_PRIVILEGED_GUEST
    1.13  	help
    1.14  	  The PCI device backend driver allows the kernel to export arbitrary
    1.15  	  PCI devices to other guests.
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/Makefile	Wed Mar 08 17:32:36 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/Makefile	Wed Mar 08 18:41:12 2006 +0100
     2.3 @@ -1,9 +1,9 @@
     2.4 -obj-y += pciback.o
     2.5 +obj-$(CONFIG_XEN_PCIDEV_BACKEND) += pciback.o
     2.6  
     2.7  pciback-y := pci_stub.o pciback_ops.o xenbus.o
     2.8  pciback-y += conf_space.o conf_space_header.o
     2.9 -pciback-${CONFIG_XEN_PCIDEV_BACKEND_VPCI} += vpci.o
    2.10 -pciback-${CONFIG_XEN_PCIDEV_BACKEND_PASS} += passthrough.o
    2.11 +pciback-$(CONFIG_XEN_PCIDEV_BACKEND_VPCI) += vpci.o
    2.12 +pciback-$(CONFIG_XEN_PCIDEV_BACKEND_PASS) += passthrough.o
    2.13  
    2.14  ifeq ($(CONFIG_XEN_PCIDEV_BE_DEBUG),y)
    2.15  EXTRA_CFLAGS += -DDEBUG
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_header.c	Wed Mar 08 17:32:36 2006 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_header.c	Wed Mar 08 18:41:12 2006 +0100
     3.3 @@ -24,21 +24,19 @@ static int command_write(struct pci_dev 
     3.4  		if (unlikely(verbose_request))
     3.5  			printk(KERN_DEBUG "pciback: %s: enable\n",
     3.6  			       pci_name(dev));
     3.7 -		dev->is_enabled = 1;
     3.8 -		pcibios_enable_device(dev, (1 << PCI_NUM_RESOURCES) - 1);
     3.9 +		pci_enable_device(dev);
    3.10  	} else if (dev->is_enabled && !is_enable_cmd(value)) {
    3.11  		if (unlikely(verbose_request))
    3.12  			printk(KERN_DEBUG "pciback: %s: disable\n",
    3.13  			       pci_name(dev));
    3.14 -		pciback_disable_device(dev);
    3.15 +		pci_disable_device(dev);
    3.16  	}
    3.17  
    3.18  	if (!dev->is_busmaster && is_master_cmd(value)) {
    3.19  		if (unlikely(verbose_request))
    3.20  			printk(KERN_DEBUG "pciback: %s: set bus master\n",
    3.21  			       pci_name(dev));
    3.22 -		dev->is_busmaster = 1;
    3.23 -		pcibios_set_master(dev);
    3.24 +		pci_set_master(dev);
    3.25  	}
    3.26  
    3.27  	if (value & PCI_COMMAND_INVALIDATE) {
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c	Wed Mar 08 17:32:36 2006 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c	Wed Mar 08 18:41:12 2006 +0100
     4.3 @@ -208,8 +208,6 @@ static int __init pcistub_init_devices_l
     4.4  	return 0;
     4.5  }
     4.6  
     4.7 -device_initcall(pcistub_init_devices_late);
     4.8 -
     4.9  static int __devinit pcistub_seize(struct pci_dev *dev)
    4.10  {
    4.11  	struct pci_stub_device *psdev;
    4.12 @@ -367,6 +365,7 @@ static int __init pcistub_init(void)
    4.13  	return -EINVAL;
    4.14  }
    4.15  
    4.16 +#ifndef MODULE
    4.17  /*
    4.18   * fs_initcall happens before device_initcall
    4.19   * so pciback *should* get called first (b/c we 
    4.20 @@ -375,3 +374,34 @@ static int __init pcistub_init(void)
    4.21   * driver to register)
    4.22   */
    4.23  fs_initcall(pcistub_init);
    4.24 +#endif
    4.25 +
    4.26 +static int __init pciback_init(void)
    4.27 +{
    4.28 +#ifndef MODULE
    4.29 +	int err;
    4.30 +
    4.31 +	err = pcistub_init();
    4.32 +	if (err < 0)
    4.33 +		return err;
    4.34 +#endif
    4.35 +
    4.36 +	if (list_empty(&pci_stub_device_ids))
    4.37 +		return -ENODEV;
    4.38 +	pcistub_init_devices_late();
    4.39 +	pciback_xenbus_register();
    4.40 +
    4.41 +	__unsafe(THIS_MODULE);
    4.42 +
    4.43 +	return 0;
    4.44 +}
    4.45 +
    4.46 +static void pciback_cleanup(void)
    4.47 +{
    4.48 +	BUG();
    4.49 +}
    4.50 +
    4.51 +module_init(pciback_init);
    4.52 +module_exit(pciback_cleanup);
    4.53 +
    4.54 +MODULE_LICENSE("Dual BSD/GPL");
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/pciback.h	Wed Mar 08 17:32:36 2006 +0100
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/pciback.h	Wed Mar 08 18:41:12 2006 +0100
     5.3 @@ -43,7 +43,6 @@ struct pci_dev *pcistub_get_pci_dev(stru
     5.4  void pcistub_put_pci_dev(struct pci_dev *dev);
     5.5  
     5.6  /* Ensure a device is turned off or reset */
     5.7 -void pciback_disable_device(struct pci_dev *dev);
     5.8  void pciback_reset_device(struct pci_dev *pdev);
     5.9  
    5.10  /* Access a virtual configuration space for a PCI device */
    5.11 @@ -69,5 +68,7 @@ void pciback_release_devices(struct pcib
    5.12  /* Handles events from front-end */
    5.13  irqreturn_t pciback_handle_event(int irq, void *dev_id, struct pt_regs *regs);
    5.14  
    5.15 +int pciback_xenbus_register(void);
    5.16 +
    5.17  extern int verbose_request;
    5.18  #endif
     6.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/pciback_ops.c	Wed Mar 08 17:32:36 2006 +0100
     6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/pciback_ops.c	Wed Mar 08 18:41:12 2006 +0100
     6.3 @@ -10,17 +10,6 @@
     6.4  int verbose_request = 0;
     6.5  module_param(verbose_request, int, 0644);
     6.6  
     6.7 -/* For those architectures without a pcibios_disable_device */
     6.8 -void __attribute__ ((weak)) pcibios_disable_device(struct pci_dev *dev) { }
     6.9 -
    6.10 -void pciback_disable_device(struct pci_dev *dev)
    6.11 -{
    6.12 -	if (dev->is_enabled) {
    6.13 -		dev->is_enabled = 0;
    6.14 -		pcibios_disable_device(dev);
    6.15 -	}
    6.16 -}
    6.17 -
    6.18  /* Ensure a device is "turned off" and ready to be exported.
    6.19   * This also sets up the device's private data to keep track of what should
    6.20   * be in the base address registers (BARs) so that we can keep the
    6.21 @@ -32,7 +21,7 @@ void pciback_reset_device(struct pci_dev
    6.22  
    6.23  	/* Disable devices (but not bridges) */
    6.24  	if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) {
    6.25 -		pciback_disable_device(dev);
    6.26 +		pci_disable_device(dev);
    6.27  
    6.28  		pci_write_config_word(dev, PCI_COMMAND, 0);
    6.29  
     7.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c	Wed Mar 08 17:32:36 2006 +0100
     7.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c	Wed Mar 08 18:41:12 2006 +0100
     7.3 @@ -430,10 +430,7 @@ static struct xenbus_driver xenbus_pciba
     7.4  	.otherend_changed 	= pciback_frontend_changed,
     7.5  };
     7.6  
     7.7 -static __init int pciback_xenbus_register(void)
     7.8 +int __init pciback_xenbus_register(void)
     7.9  {
    7.10  	return xenbus_register_backend(&xenbus_pciback_driver);
    7.11  }
    7.12 -
    7.13 -/* Must only initialize our xenbus driver after the pcistub driver */
    7.14 -device_initcall(pciback_xenbus_register);