[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [patch 3/4 v2] ioemu: allow xend to specify the slot for pass-through devices
Currently a slot may be specified for a hot-plug device, but not for a pass-through device that is inserted at boot time. This patch adds support for the latter. The syntax is: BUS:DEV.FUNC[@VSLOT] e.g: 0000:00:1d:0@7 This may be important as recent changes that allow any free PCI slot to be used for pass-through (and hotplug) may case pass-through devices to be assigned in different locations to before. Amongst other things, specifying the slot will allow users to move them back, if there is a need. There is also a xend portion of this patch, which will be posted separately. Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx> --- Some implementation details * Pass the slot parsed from xend to register_real_device(). If none was passed, next_bdf() will supply AUTO_PHP_SLOT. * Make use of the fact that __insert_to_pci_slot() is now indempotent and always call it in register_real_device() * Change the error message int he case where __insert_to_pci_slot() fails to not refer to hot-plut. e_devfn will always be non-auto in the hotplug case as register_real_device() is called by power_on_php_slot() which is called by acpi_php_add() which is called by acpi_php_add(). acpi_php_add() handles calling __insert_to_pci_slot() and acpi_php_add() handles the case where the call failed, before calling power_on_php_slot(). * Remove PT_VIRT_DEVFN_AUTO, it is no longer used. Index: ioemu-remote/hw/pass-through.c =================================================================== --- ioemu-remote.orig/hw/pass-through.c 2009-03-20 21:34:06.000000000 +1100 +++ ioemu-remote/hw/pass-through.c 2009-03-20 21:35:25.000000000 +1100 @@ -3560,7 +3560,7 @@ static int pt_pmcsr_reg_restore(struct p } struct pt_dev * register_real_device(PCIBus *e_bus, - const char *e_dev_name, int e_devfn, uint8_t r_bus, uint8_t r_dev, + const char *e_dev_name, int e_slot, uint8_t r_bus, uint8_t r_dev, uint8_t r_func, uint32_t machine_irq, struct pci_access *pci_access, char *opt) { @@ -3569,7 +3569,6 @@ struct pt_dev * register_real_device(PCI struct pci_dev *pci_dev; uint8_t e_device, e_intx; struct pci_config_cf8 machine_bdf; - int free_slot; char *key, *val; int msi_translate; @@ -3592,15 +3591,10 @@ struct pt_dev * register_real_device(PCI pci_fill_info(pci_dev, PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES); pt_libpci_fixup(pci_dev); - if ( e_devfn == PT_VIRT_DEVFN_AUTO ) { - /*indicate a static assignment(not hotplug), so find a free PCI hot plug slot */ - free_slot = __insert_to_pci_slot(r_bus, r_dev, r_func, - AUTO_PHP_SLOT, NULL); - if ( free_slot < 0 ) { - PT_LOG("Error: no free virtual PCI hot plug slot, thus no live migration.\n"); - return NULL; - } - e_devfn = free_slot << 3; + e_slot = __insert_to_pci_slot(r_bus, r_dev, r_func, e_slot, NULL); + if ( e_slot < 0 ) { + PT_LOG("Error: no free virtual PCI slot\n"); + return NULL; } msi_translate = direct_pci_msitranslate; @@ -3633,7 +3627,7 @@ struct pt_dev * register_real_device(PCI /* Register device */ assigned_device = (struct pt_dev *) pci_register_device(e_bus, e_dev_name, - sizeof(struct pt_dev), e_devfn, + sizeof(struct pt_dev), PCI_DEVFN(e_slot, 0), pt_pci_read_config, pt_pci_write_config); if ( assigned_device == NULL ) { @@ -3641,7 +3635,7 @@ struct pt_dev * register_real_device(PCI return NULL; } - dpci_infos.php_devs[PCI_SLOT(e_devfn)].pt_dev = assigned_device; + dpci_infos.php_devs[e_slot].pt_dev = assigned_device; assigned_device->pci_dev = pci_dev; assigned_device->msi_trans_cap = msi_translate; @@ -3802,7 +3796,7 @@ int power_on_php_slot(int slot) pt_dev = register_real_device(dpci_infos.e_bus, "DIRECT PCI", - slot << 3, + slot, php_dev->r_bus, php_dev->r_dev, php_dev->r_func, @@ -3862,7 +3856,7 @@ int pt_init(PCIBus *e_bus, const char *d while ( next_bdf(&direct_pci_p, &seg, &b, &d, &f, &opt, &s) ) { /* Register real device with the emulated bus */ - pt_dev = register_real_device(e_bus, "DIRECT PCI", PT_VIRT_DEVFN_AUTO, + pt_dev = register_real_device(e_bus, "DIRECT PCI", s, b, d, f, PT_MACHINE_IRQ_AUTO, pci_access, opt); if ( pt_dev == NULL ) { Index: ioemu-remote/hw/pass-through.h =================================================================== --- ioemu-remote.orig/hw/pass-through.h 2009-03-20 21:24:13.000000000 +1100 +++ ioemu-remote/hw/pass-through.h 2009-03-20 21:35:25.000000000 +1100 @@ -39,7 +39,6 @@ // #define PT_DEBUG_PCI_CONFIG_ACCESS #define PT_MACHINE_IRQ_AUTO (0xFFFFFFFF) -#define PT_VIRT_DEVFN_AUTO (-1) /* Misc PCI constants that should be moved to a separate library :) */ #define PCI_CONFIG_SIZE (256) -- -- Simon Horman VA Linux Systems Japan K.K., Sydney, Australia Satellite Office H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |