diff --git a/share/man/man4/pci.4 b/share/man/man4/pci.4 --- a/share/man/man4/pci.4 +++ b/share/man/man4/pci.4 @@ -244,6 +244,12 @@ This should always be equivalent to the offset of the .Va pc_spare member. +.It pc_secbus +Secondary PCI bus number. +.Pq Only valid for bridge devices +.It pc_subbus +Subordinate PCI bus number. +.Pq Only valid for bridge devices .It pc_spare Reserved for future use. .El diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -798,6 +798,9 @@ devlist_entry->conf.pc_progif = cfg->progif; devlist_entry->conf.pc_revid = cfg->revid; + devlist_entry->conf.pc_secbus = cfg->bridge.br_secbus; + devlist_entry->conf.pc_subbus = cfg->bridge.br_subbus; + pci_numdevs++; pci_generation++; diff --git a/sys/dev/pci/pci_user.c b/sys/dev/pci/pci_user.c --- a/sys/dev/pci/pci_user.c +++ b/sys/dev/pci/pci_user.c @@ -81,7 +81,9 @@ u_int32_t pd_unit; /* device unit number */ int pd_numa_domain; /* device NUMA domain */ u_int32_t pc_reported_len;/* length of PCI data reported */ - char pc_spare[64]; /* space for future fields */ + uint8_t pc_secbus; /* secondary bus number */ + uint8_t pc_subbus; /* subordinate bus number */ + char pc_spare[62]; /* space for future fields */ }; struct pci_match_conf32 { @@ -889,6 +891,8 @@ pcup->pc32.pd_unit = (uint32_t)pcp->pd_unit; if (cmd == PCIOCGETCONF32) { pcup->pc32.pd_numa_domain = pcp->pd_numa_domain; + pcup->pc32.pc_secbus = pcp->pc_secbus; + pcup->pc32.pc_subbus = pcp->pc_subbus; pcup->pc32.pc_reported_len = (uint32_t)offsetof(struct pci_conf32, pc_spare); } @@ -1315,6 +1319,32 @@ else dinfo->conf.pd_numa_domain = 0; + if (dinfo->cfg.dev != NULL) { + /* + * Re-read the values in case a driver + * changed them after the device was + * initially scanned. + */ + switch (dinfo->conf.pc_hdr) { + case PCIM_HDRTYPE_BRIDGE: + dinfo->conf.pc_secbus = + pci_read_config(dinfo->cfg.dev, + PCIR_SECBUS_1, 1); + dinfo->conf.pc_subbus = + pci_read_config(dinfo->cfg.dev, + PCIR_SUBBUS_1, 1); + break; + case PCIM_HDRTYPE_CARDBUS: + dinfo->conf.pc_secbus = + pci_read_config(dinfo->cfg.dev, + PCIR_SECBUS_2, 1); + dinfo->conf.pc_subbus = + pci_read_config(dinfo->cfg.dev, + PCIR_SUBBUS_2, 1); + break; + } + } + if (pattern_buf == NULL || pci_conf_match(cmd, pattern_buf, num_patterns, &dinfo->conf) == 0) { diff --git a/sys/sys/pciio.h b/sys/sys/pciio.h --- a/sys/sys/pciio.h +++ b/sys/sys/pciio.h @@ -79,7 +79,9 @@ u_long pd_unit; /* device unit number */ int pd_numa_domain; /* device NUMA domain */ size_t pc_reported_len;/* length of PCI data reported */ - char pc_spare[64]; /* space for future fields */ + uint8_t pc_secbus; /* secondary bus number */ + uint8_t pc_subbus; /* subordinate bus number */ + char pc_spare[62]; /* space for future fields */ }; struct pci_match_conf {