Skip to content

Commit

Permalink
x86: Adjust base addr for PCI MCFG regions
Browse files Browse the repository at this point in the history
Each bus gets 1 MB of address space; the actual base address for an
MCFG bus range is the address from the table plus the starting bus
number times 1 MB.

The PCI spec is unclear on this point, but this change matches what
Linux does, which is likely enough of a de facto standard regardless
of what any de jure standard might attempt to say.

Fixes:	f54a389 ("x86: Support multiple PCI MCFG regions")
Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D43206
  • Loading branch information
cperciva authored and bsdjhb committed Mar 13, 2024
2 parents 363f827 + 61e2161 commit bbb2b3e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sys/amd64/pci/pci_cfgreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ pcie_cfgregopen(uint64_t base, uint16_t domain, uint8_t minbus, uint8_t maxbus)
region = &mcfg_regions[mcfg_numregions];

/* XXX: We should make sure this really fits into the direct map. */
region->base = pmap_mapdev_pciecfg(base, (maxbus + 1 - minbus) << 20);
region->base = pmap_mapdev_pciecfg(base + (minbus << 20), (maxbus + 1 - minbus) << 20);
region->domain = domain;
region->minbus = minbus;
region->maxbus = maxbus;
Expand Down
2 changes: 1 addition & 1 deletion sys/i386/pci/pci_cfgreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ pcie_cfgregopen(uint64_t base, uint16_t domain, uint8_t minbus, uint8_t maxbus)
sizeof(*mcfg_regions) * (mcfg_numregions + 1), M_DEVBUF, M_WAITOK);

region = &mcfg_regions[mcfg_numregions];
region->base = base;
region->base = base + (minbus << 20);
region->domain = domain;
region->minbus = minbus;
region->maxbus = maxbus;
Expand Down

0 comments on commit bbb2b3e

Please sign in to comment.