Skip to content

PCI fixes - #165

Merged
d-tatianin merged 8 commits into
masterfrom
various-fixes
Oct 7, 2026
Merged

d-tatianin merged 8 commits into
masterfrom
various-fixes

Conversation

@d-tatianin

Copy link
Copy Markdown
Contributor

No description provided.

A PCI_Config region was always attached to the bus returned by _BBN of
the PCI root, with the device & function taken from _ADR of the device
it was declared in. This is only correct for devices that sit directly
on the root bus: anything below a PCI-to-PCI bridge lives on the
secondary bus of that bridge.

Figure out which device a region belongs to the same way the NT ACPI
driver does it, as observed on Windows 11 with a set of probe tables:

- A device is only a PCI device if it has an _ADR and its direct parent
  is either the PCI root or a PCI device that is a bridge, in which case
  it is on the secondary bus of that bridge. Whether something is a
  bridge is decided by its header type, both PCI & CardBus ones count.
- The region belongs to the closest PCI device at or above the device it
  was declared in. In particular, anything below a non-bridge, like a
  port of a USB controller, uses the config space of that non-bridge
  no matter what its own _ADR is, and so does a device without an _ADR.
- The bus numbers are re-read every time as they're host writable and
  not known to AML.

The handles of the bridges & of the device itself are kept open, and are
only reopened if the address they were opened at changes.

While at it, don't treat the handle as valid if opening the device
failed with something other than UACPI_STATUS_NOT_FOUND.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
Make the test runner provide a small fake PCI topology on segment 0xCAFE
that has a few bridges in it, with writable secondary bus numbers, and a
bus that nothing can be opened on.

Use it to check that PCI_Config regions are attached to the correct
device, and that they follow the bridges above them as those get
configured, moved to a different bus & deconfigured.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
Exact same protection list that ships with Windows 11's ACPI driver.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
Exact same protection list that ships with Windows 11's ACPI driver.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
NT doesn't assume that no _ADR implies 00:00.0, so we shouldn't either.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
@d-tatianin
d-tatianin merged commit 2cb5e71 into master Oct 7, 2026
4 checks passed
@d-tatianin
d-tatianin deleted the various-fixes branch October 7, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant