aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2023-05-18 21:40:44 +0200
committerMartin Mares <mj@ucw.cz>2024-02-18 16:18:43 +0100
commite4517524ca872caa5e89d7df50cd91aac476b7be (patch)
tree6e451f15c3440dc5feacc3140082f033e58a7b16
parent67b471f2fa71295b325a574c140faa2735d95781 (diff)
downloadpciutils-e4517524ca872caa5e89d7df50cd91aac476b7be.tar.gz
libpci: ecam: Cache ACPI MCFG table between detect() and init() phase
This will speed up listing devices by lspci as it is not needed to scan BIOS memory two times.
-rw-r--r--lib/ecam.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/ecam.c b/lib/ecam.c
index 7c68816..f088c0c 100644
--- a/lib/ecam.c
+++ b/lib/ecam.c
@@ -898,10 +898,6 @@ ecam_detect(struct pci_access *a)
a->backend_data = NULL;
return 0;
}
- pci_mfree(eacc->mcfg);
- physmem_close(eacc->physmem);
- pci_mfree(eacc);
- a->backend_data = NULL;
}
if (use_addrs)
@@ -925,7 +921,7 @@ ecam_init(struct pci_access *a)
#endif
const char *addrs = pci_get_param(a, "ecam.addrs");
struct physmem *physmem = NULL;
- struct ecam_access *eacc = NULL;
+ struct ecam_access *eacc = a->backend_data;
long pagesize = 0;
int use_bsd = 0;
int use_x86bios = 0;
@@ -936,20 +932,23 @@ ecam_init(struct pci_access *a)
if (!validate_addrs(addrs))
a->error("Option ecam.addrs has invalid address format \"%s\".", addrs);
- physmem = physmem_open(a, a->writeable);
- if (!physmem)
- a->error("Cannot open physcal memory: %s.", strerror(errno));
+ if (!eacc)
+ {
+ physmem = physmem_open(a, a->writeable);
+ if (!physmem)
+ a->error("Cannot open physcal memory: %s.", strerror(errno));
- pagesize = physmem_get_pagesize(physmem);
- if (pagesize <= 0)
- a->error("Cannot get page size: %s.", strerror(errno));
+ pagesize = physmem_get_pagesize(physmem);
+ if (pagesize <= 0)
+ a->error("Cannot get page size: %s.", strerror(errno));
- eacc = pci_malloc(a, sizeof(*eacc));
- eacc->mcfg = NULL;
- eacc->cache = NULL;
- eacc->physmem = physmem;
- eacc->pagesize = pagesize;
- a->backend_data = eacc;
+ eacc = pci_malloc(a, sizeof(*eacc));
+ eacc->mcfg = NULL;
+ eacc->cache = NULL;
+ eacc->physmem = physmem;
+ eacc->pagesize = pagesize;
+ a->backend_data = eacc;
+ }
if (!*addrs)
{
@@ -961,7 +960,8 @@ ecam_init(struct pci_access *a)
if (strcmp(x86bios, "0") != 0)
use_x86bios = 1;
#endif
- eacc->mcfg = find_mcfg(a, acpimcfg, efisystab, use_bsd, use_x86bios);
+ if (!eacc->mcfg)
+ eacc->mcfg = find_mcfg(a, acpimcfg, efisystab, use_bsd, use_x86bios);
if (!eacc->mcfg)
a->error("Option ecam.addrs was not specified and ACPI MCFG table cannot be found.");
}