diff options
author | Pali Rohár <pali@kernel.org> | 2023-05-08 21:25:36 +0200 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2024-02-18 16:18:43 +0100 |
commit | 67b471f2fa71295b325a574c140faa2735d95781 (patch) | |
tree | 5fe59b77b581821d7572dbe5d2696cb388f03717 | |
parent | 93c02ab2b8682c0399a7bf784b34c1028d0747d1 (diff) | |
download | pciutils-67b471f2fa71295b325a574c140faa2735d95781.tar.gz |
libpci: ecam: Fix detect sequence when addresses are not specified
Search for ACPI MCFG table in detect sequence, so on failure we can move to
the next pci access method.
-rw-r--r-- | lib/ecam.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -790,6 +790,7 @@ ecam_detect(struct pci_access *a) const char *x86bios = pci_get_param(a, "ecam.x86bios"); #endif const char *addrs = pci_get_param(a, "ecam.addrs"); + struct ecam_access *eacc; glob_t mcfg_glob; int ret; @@ -865,6 +866,44 @@ ecam_detect(struct pci_access *a) return 0; } + if (!use_addrs) + { + eacc = pci_malloc(a, sizeof(*eacc)); + + eacc->physmem = physmem_open(a, a->writeable); + if (!eacc->physmem) + { + a->debug("cannot open physcal memory: %s.", strerror(errno)); + pci_mfree(eacc); + return 0; + } + + eacc->pagesize = physmem_get_pagesize(eacc->physmem); + if (eacc->pagesize <= 0) + { + a->debug("Cannot get page size: %s.", strerror(errno)); + physmem_close(eacc->physmem); + pci_mfree(eacc); + return 0; + } + + eacc->mcfg = NULL; + eacc->cache = NULL; + a->backend_data = eacc; + eacc->mcfg = find_mcfg(a, acpimcfg, efisystab, use_bsd, use_x86bios); + if (!eacc->mcfg) + { + physmem_close(eacc->physmem); + pci_mfree(eacc); + a->backend_data = NULL; + return 0; + } + pci_mfree(eacc->mcfg); + physmem_close(eacc->physmem); + pci_mfree(eacc); + a->backend_data = NULL; + } + if (use_addrs) a->debug("using with ecam addresses %s", addrs); else |