Since pci devices could reside in different domains now, we should judge the domain of pci devices when traversing them. Original devices still use domain 0 for compatibility
Signed-off-by: Zihan Yang whois.zihan.yang@gmail.com --- src/fw/mptable.c | 1 + src/fw/pciinit.c | 10 ++++------ src/hw/ahci.c | 1 + src/hw/ata.c | 1 + src/hw/esp-scsi.c | 1 + src/hw/lsi-scsi.c | 1 + src/hw/megasas.c | 1 + src/hw/mpt-scsi.c | 1 + src/hw/nvme.c | 1 + src/hw/pcidevice.c | 3 +++ src/hw/pcidevice.h | 4 ++++ src/hw/pvscsi.c | 1 + src/hw/sdcard.c | 1 + src/hw/usb-ehci.c | 1 + src/hw/usb-ohci.c | 1 + src/hw/usb-uhci.c | 1 + src/hw/usb-xhci.c | 1 + src/hw/virtio-blk.c | 1 + src/hw/virtio-scsi.c | 1 + src/optionroms.c | 3 +++ 20 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/src/fw/mptable.c b/src/fw/mptable.c index 47385cc..3989cb6 100644 --- a/src/fw/mptable.c +++ b/src/fw/mptable.c @@ -110,6 +110,7 @@ mptable_setup(void)
struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); u16 bdf = pci->bdf; if (pci_bdf_to_bus(bdf) != 0) break; diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index fcdcd38..834540f 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -427,8 +427,7 @@ static void pci_bios_init_devices(int domain_nr) { struct pci_device *pci; foreachpci(pci) { - if (pci->domain_nr != domain_nr) - continue; + filter_domain(pci, domain_nr); pci_bios_init_device(pci); } } @@ -438,6 +437,7 @@ static void pci_enable_default_vga(void) struct pci_device *pci;
foreachpci(pci) { + filter_domain(pci, 0); if (is_pci_vga(pci)) { dprintf(1, "PCI: Using %pP for primary VGA\n", pci); return; @@ -545,8 +545,7 @@ static void pci_bios_init_platform(int domain_nr) { struct pci_device *pci; foreachpci(pci) { - if (pci->domain_nr != domain_nr) - continue; + filter_domain(pci, domain_nr); pci_init_device(pci_platform_tbl, pci, NULL); } } @@ -884,8 +883,7 @@ static int pci_bios_check_devices(struct pci_bus *busses, int domain_nr) // Calculate resources needed for regular (non-bus) devices. struct pci_device *pci; foreachpci(pci) { - if (pci->domain_nr != domain_nr) - continue; + filter_domain(pci, domain_nr); if (pci->class == PCI_CLASS_BRIDGE_PCI) busses[pci->secondary_bus].bus_dev = pci;
diff --git a/src/hw/ahci.c b/src/hw/ahci.c index 1746e7a..f825992 100644 --- a/src/hw/ahci.c +++ b/src/hw/ahci.c @@ -677,6 +677,7 @@ ahci_scan(void) // Scan PCI bus for ATA adapters struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->class != PCI_CLASS_STORAGE_SATA) continue; if (pci->prog_if != 1 /* AHCI rev 1 */) diff --git a/src/hw/ata.c b/src/hw/ata.c index b6e073c..2273326 100644 --- a/src/hw/ata.c +++ b/src/hw/ata.c @@ -1024,6 +1024,7 @@ ata_scan(void) // Scan PCI bus for ATA adapters struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); pci_init_device(pci_ata_tbl, pci, NULL); } } diff --git a/src/hw/esp-scsi.c b/src/hw/esp-scsi.c index ffd86d0..17436d5 100644 --- a/src/hw/esp-scsi.c +++ b/src/hw/esp-scsi.c @@ -233,6 +233,7 @@ esp_scsi_setup(void)
struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor != PCI_VENDOR_ID_AMD || pci->device != PCI_DEVICE_ID_AMD_SCSI) continue; diff --git a/src/hw/lsi-scsi.c b/src/hw/lsi-scsi.c index d5fc3e4..5748d1f 100644 --- a/src/hw/lsi-scsi.c +++ b/src/hw/lsi-scsi.c @@ -213,6 +213,7 @@ lsi_scsi_setup(void)
struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor != PCI_VENDOR_ID_LSI_LOGIC || pci->device != PCI_DEVICE_ID_LSI_53C895A) continue; diff --git a/src/hw/megasas.c b/src/hw/megasas.c index d267580..1d84771 100644 --- a/src/hw/megasas.c +++ b/src/hw/megasas.c @@ -386,6 +386,7 @@ megasas_setup(void)
struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor != PCI_VENDOR_ID_LSI_LOGIC && pci->vendor != PCI_VENDOR_ID_DELL) continue; diff --git a/src/hw/mpt-scsi.c b/src/hw/mpt-scsi.c index 1faede6..e89316b 100644 --- a/src/hw/mpt-scsi.c +++ b/src/hw/mpt-scsi.c @@ -310,6 +310,7 @@ mpt_scsi_setup(void)
struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor == PCI_VENDOR_ID_LSI_LOGIC && (pci->device == PCI_DEVICE_ID_LSI_53C1030 || pci->device == PCI_DEVICE_ID_LSI_SAS1068 diff --git a/src/hw/nvme.c b/src/hw/nvme.c index e6d739d..d7b5183 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -633,6 +633,7 @@ nvme_scan(void) struct pci_device *pci;
foreachpci(pci) { + filter_domain(pci, 0); if (pci->class != PCI_CLASS_STORAGE_NVME) continue; if (pci->prog_if != 2 /* as of NVM 1.0e */) { diff --git a/src/hw/pcidevice.c b/src/hw/pcidevice.c index ec21ec1..44dc05a 100644 --- a/src/hw/pcidevice.c +++ b/src/hw/pcidevice.c @@ -91,6 +91,7 @@ pci_find_device(u16 vendid, u16 devid) { struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor == vendid && pci->device == devid) return pci; } @@ -103,6 +104,7 @@ pci_find_class(u16 classid) { struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->class == classid) return pci; } @@ -130,6 +132,7 @@ pci_find_init_device(const struct pci_device_id *ids, void *arg) { struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci_init_device(ids, pci, arg) == 0) return pci; } diff --git a/src/hw/pcidevice.h b/src/hw/pcidevice.h index 951e005..4518e77 100644 --- a/src/hw/pcidevice.h +++ b/src/hw/pcidevice.h @@ -32,6 +32,10 @@ static inline u32 pci_classprog(struct pci_device *pci) { #define foreachpci(PCI) \ hlist_for_each_entry(PCI, &PCIDevices, node)
+#define filter_domain(PCI, DOMAIN) \ + if ((PCI)->domain_nr != (DOMAIN)) \ + continue; + #define PCI_ANY_ID (~0) struct pci_device_id { u32 vendid; diff --git a/src/hw/pvscsi.c b/src/hw/pvscsi.c index d62d0a0..d0f6dac 100644 --- a/src/hw/pvscsi.c +++ b/src/hw/pvscsi.c @@ -325,6 +325,7 @@ pvscsi_setup(void)
struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor != PCI_VENDOR_ID_VMWARE || pci->device != PCI_DEVICE_ID_VMWARE_PVSCSI) continue; diff --git a/src/hw/sdcard.c b/src/hw/sdcard.c index 6410340..f3782f2 100644 --- a/src/hw/sdcard.c +++ b/src/hw/sdcard.c @@ -564,6 +564,7 @@ sdcard_setup(void)
struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->class != PCI_CLASS_SYSTEM_SDHCI || pci->prog_if >= 2) // Not an SDHCI controller following SDHCI spec continue; diff --git a/src/hw/usb-ehci.c b/src/hw/usb-ehci.c index 7eca55b..60b73b2 100644 --- a/src/hw/usb-ehci.c +++ b/src/hw/usb-ehci.c @@ -331,6 +331,7 @@ ehci_setup(void) return; struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_EHCI) ehci_controller_setup(pci); } diff --git a/src/hw/usb-ohci.c b/src/hw/usb-ohci.c index 90f60e6..c25745f 100644 --- a/src/hw/usb-ohci.c +++ b/src/hw/usb-ohci.c @@ -302,6 +302,7 @@ ohci_setup(void) return; struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_OHCI) ohci_controller_setup(pci); } diff --git a/src/hw/usb-uhci.c b/src/hw/usb-uhci.c index 075ed02..f92b417 100644 --- a/src/hw/usb-uhci.c +++ b/src/hw/usb-uhci.c @@ -275,6 +275,7 @@ uhci_setup(void) return; struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_UHCI) uhci_controller_setup(pci); } diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c index 08d1e32..9293720 100644 --- a/src/hw/usb-xhci.c +++ b/src/hw/usb-xhci.c @@ -631,6 +631,7 @@ xhci_setup(void) return; struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_XHCI) xhci_controller_setup(pci); } diff --git a/src/hw/virtio-blk.c b/src/hw/virtio-blk.c index 88d7e54..2a98303 100644 --- a/src/hw/virtio-blk.c +++ b/src/hw/virtio-blk.c @@ -202,6 +202,7 @@ virtio_blk_setup(void)
struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor != PCI_VENDOR_ID_REDHAT_QUMRANET || (pci->device != PCI_DEVICE_ID_VIRTIO_BLK_09 && pci->device != PCI_DEVICE_ID_VIRTIO_BLK_10)) diff --git a/src/hw/virtio-scsi.c b/src/hw/virtio-scsi.c index a87cad8..b77680e 100644 --- a/src/hw/virtio-scsi.c +++ b/src/hw/virtio-scsi.c @@ -211,6 +211,7 @@ virtio_scsi_setup(void)
struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor != PCI_VENDOR_ID_REDHAT_QUMRANET || (pci->device != PCI_DEVICE_ID_VIRTIO_SCSI_09 && pci->device != PCI_DEVICE_ID_VIRTIO_SCSI_10)) diff --git a/src/optionroms.c b/src/optionroms.c index fc992f6..527b7cb 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -350,6 +350,7 @@ optionrom_setup(void) // Find and deploy PCI roms. struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->class == PCI_CLASS_DISPLAY_VGA || pci->class == PCI_CLASS_DISPLAY_OTHER || pci->have_driver) @@ -409,6 +410,7 @@ static void try_setup_display_other(void) dprintf(1, "No VGA found, scan for other display\n");
foreachpci(pci) { + filter_domain(pci, 0); if (pci->class != PCI_CLASS_DISPLAY_OTHER) continue; struct rom_header *rom = map_pcirom(pci); @@ -445,6 +447,7 @@ vgarom_setup(void) // Find and deploy PCI VGA rom. struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (!is_pci_vga(pci)) continue; vgahook_setup(pci);