From nobody Wed Dec 17 06:04:07 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1533793521002433.8486050229791; Wed, 8 Aug 2018 22:45:21 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coreboot.org) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1fndm0-0001DD-6v; Thu, 09 Aug 2018 07:46:12 +0200 Received: from mail-pl0-f65.google.com ([209.85.160.65]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_2) (envelope-from ) id 1fndlm-0001BT-4b for seabios@seabios.org; Thu, 09 Aug 2018 07:46:09 +0200 Received: by mail-pl0-f65.google.com with SMTP id t17-v6so2052979ply.13 for ; Wed, 08 Aug 2018 22:44:16 -0700 (PDT) Received: from bloodymary.ipads-lab.se.sjtu.edu.cn (45.78.72.26.16clouds.com. [45.78.72.26]) by smtp.gmail.com with ESMTPSA id j27-v6sm11515584pfj.91.2018.08.08.22.44.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Aug 2018 22:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Pyy++2mASS+nnWVRXlRl24QUcKF8R93spibLB8eUdlg=; b=pr77p7Xet0EjzhSoS99DC0cPZzydxRWJ65JQYZOb6SC/4ex+hcdPWJ2s9HUs+O8j6n MOjPl9MBD5AzMUCBobzqUIw6pGp+xY17w8gPZT7dwzSdnhcn1WGfptgKPrrqp4tTqqyK tsShPeAqZqdCWvDCaJkTu4ZHJzSQpkgMU9yuxbrj6DVP3VD8z5/hY9dsn5y7W2B6ACiV QKAcm6TCVcAcL+HpoHgBFmTZS2f/f1KtGHEzA21IJlSFat9JOKPdSr0eEqQGy/tOFs79 o32NTyARWVacBGQf10q5TjxMo6xWV5MuOqTyka19J9si8WhNc3N6LWoBj8EoJU7FApe2 0nDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Pyy++2mASS+nnWVRXlRl24QUcKF8R93spibLB8eUdlg=; b=OuFlnKn0wMd4fYDbGdn3wSGqmOEun9U5PeZ3bVZD4NZJND+zyx1vRjHFoB1cJN58kw 1Yt+quRA5suQE5EJs94v6ihZM8Uo52QqQxt488FD4RH8BJPRNlarB8C6o8cpUkqR2SJD RbTOiAGWtCzRzSrDfqakAY5avTg4EtHU8zh+DBUPqT5hlwxSvF7aaKMarcHnlfKrPPEO TfSyQIh+zRgtgK/43zU8VWVC2MRYQxm7ugU43pPbUjiKqp4BuR5lkyI+UKtURs/tdXej payHSZBhfiSayUlCtkeJ55hcOxJpa9TV9vYrveHQUQHDPNT/1Sye/8xVw2qRabB+9AoV y+Iw== X-Gm-Message-State: AOUpUlHret9UF1hti5wtZEYfDcEpn5XMiNk6DqB7K6mC3n1EJ9dtMs7Y 3PXeVIQ4Jm/pHQy4TcCkg/zZO+XszkE= X-Google-Smtp-Source: AA+uWPy/pqRegc/hvIKpWMnYfAJGsmAAjk54WuDAFj+rtyP6uJ1qrXm86agwVgW3Bb/iREV/brjEkA== X-Received: by 2002:a17:902:143:: with SMTP id 61-v6mr689102plb.171.1533793453592; Wed, 08 Aug 2018 22:44:13 -0700 (PDT) From: Zihan Yang To: seabios@seabios.org Date: Thu, 9 Aug 2018 13:43:54 +0800 Message-Id: <1533793434-7614-4-git-send-email-whois.zihan.yang@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533793434-7614-1-git-send-email-whois.zihan.yang@gmail.com> References: <1533793434-7614-1-git-send-email-whois.zihan.yang@gmail.com> X-Spam-Score: -4.5 (----) Subject: [SeaBIOS] [RFC v2 3/3] pci: filter undesired domain when traversing pci X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zihan Yang MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 --- 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) =20 struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); u16 bdf =3D pci->bdf; if (pci_bdf_to_bus(bdf) !=3D 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 !=3D 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; =20 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 !=3D 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 *busse= s, int domain_nr) // Calculate resources needed for regular (non-bus) devices. struct pci_device *pci; foreachpci(pci) { - if (pci->domain_nr !=3D domain_nr) - continue; + filter_domain(pci, domain_nr); if (pci->class =3D=3D PCI_CLASS_BRIDGE_PCI) busses[pci->secondary_bus].bus_dev =3D pci; =20 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 !=3D PCI_CLASS_STORAGE_SATA) continue; if (pci->prog_if !=3D 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) =20 struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor !=3D PCI_VENDOR_ID_AMD || pci->device !=3D 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) =20 struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor !=3D PCI_VENDOR_ID_LSI_LOGIC || pci->device !=3D 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) =20 struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor !=3D PCI_VENDOR_ID_LSI_LOGIC && pci->vendor !=3D 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) =20 struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor =3D=3D PCI_VENDOR_ID_LSI_LOGIC && (pci->device =3D=3D PCI_DEVICE_ID_LSI_53C1030 || pci->device =3D=3D 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; =20 foreachpci(pci) { + filter_domain(pci, 0); if (pci->class !=3D PCI_CLASS_STORAGE_NVME) continue; if (pci->prog_if !=3D 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 =3D=3D vendid && pci->device =3D=3D 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 =3D=3D classid) return pci; } @@ -130,6 +132,7 @@ pci_find_init_device(const struct pci_device_id *ids, v= oid *arg) { struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci_init_device(ids, pci, arg) =3D=3D 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) =20 +#define filter_domain(PCI, DOMAIN) \ + if ((PCI)->domain_nr !=3D (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) =20 struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor !=3D PCI_VENDOR_ID_VMWARE || pci->device !=3D 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) =20 struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->class !=3D PCI_CLASS_SYSTEM_SDHCI || pci->prog_if >=3D 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) =3D=3D 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) =3D=3D 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) =3D=3D 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) =3D=3D 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) =20 struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor !=3D PCI_VENDOR_ID_REDHAT_QUMRANET || (pci->device !=3D PCI_DEVICE_ID_VIRTIO_BLK_09 && pci->device !=3D 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) =20 struct pci_device *pci; foreachpci(pci) { + filter_domain(pci, 0); if (pci->vendor !=3D PCI_VENDOR_ID_REDHAT_QUMRANET || (pci->device !=3D PCI_DEVICE_ID_VIRTIO_SCSI_09 && pci->device !=3D 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 =3D=3D PCI_CLASS_DISPLAY_VGA || pci->class =3D=3D 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"); =20 foreachpci(pci) { + filter_domain(pci, 0); if (pci->class !=3D PCI_CLASS_DISPLAY_OTHER) continue; struct rom_header *rom =3D 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); --=20 2.7.4 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios