Skip to content

Refactored PCIe drivers#75

Merged
EDGW merged 3 commits intomainfrom
dev/kako/pci
Apr 29, 2026
Merged

Refactored PCIe drivers#75
EDGW merged 3 commits intomainfrom
dev/kako/pci

Conversation

@EDGW
Copy link
Copy Markdown
Member

@EDGW EDGW commented Apr 28, 2026

Refactored the PCIe driver to fix the issue of PCIe being unavailable on RISC-V.

AI Usage Status

AI is used in generating docs.

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 28, 2026 13:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the kernel PCIe stack to improve ECAM host-bridge probing, bus enumeration, and resource/BAR allocation (aimed at restoring PCIe availability on RISC-V), and updates QEMU platform configs accordingly.

Changes:

  • Split PCIe “domain” concerns into dedicated modules (resources/apertures/interrupt routing) and updated host-bridge probing to populate them from DT properties.
  • Reworked PCIe bridge/bus enumeration and introduced an explicit resource-allocation stage (alloc_resources) for BAR/aperture programming.
  • Updated PCIe remap registry semantics (store Weak<IoRemap>) and modernized ECAM/address-type utilities and docs.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
conf/platforms/qemu-virt-rv64.toml Adds commented QEMU PCIe virtio-blk configuration snippets.
conf/platforms/qemu-virt-la64.toml Adjusts rootfs block device path to vdb.
anemone-kernel/src/driver/virtio/pcie.rs Updates PCI function identifier type and endpoint matching.
anemone-kernel/src/driver/pcie_drivers/platform.rs Refactors generic ECAM host-bridge probe to build a PcieDomain from DT ranges/interrupt-map.
anemone-kernel/src/driver/pcie_drivers/mod.rs Adds module docs and fixes module ordering.
anemone-kernel/src/driver/pcie_drivers/bus.rs Major rewrite of bridge driver: enumeration, resource allocation, and teardown logic.
anemone-kernel/src/device/mod.rs Enhances device listing output with device-kind labeling.
anemone-kernel/src/device/bus/pcie/remap.rs Changes remap registry to store Weak<IoRemap> and lazily purge expired entries.
anemone-kernel/src/device/bus/pcie/mod.rs Exposes new domain module and renames class-code constants.
anemone-kernel/src/device/bus/pcie/fwnode.rs Updates interrupt-info type imports and adds docs.
anemone-kernel/src/device/bus/pcie/ecam.rs Adds richer typed helpers/iterators and more ECAM/config-space documentation.
anemone-kernel/src/device/bus/pcie/driver.rs Introduces BAR probing/allocation + default alloc_resources hook in PcieDriver.
anemone-kernel/src/device/bus/pcie/domain/resources.rs New PCIe domain resource manager (bus numbers, apertures, IRQ routing).
anemone-kernel/src/device/bus/pcie/domain/mod.rs New domain module wrapper and domain ID type.
anemone-kernel/src/device/bus/pcie/domain/intr.rs New interrupt routing table with mask-based matching.
anemone-kernel/src/device/bus/pcie/domain/aperture.rs New aperture allocators + AvailableApertures selection for BAR allocation.
anemone-kernel/src/device/bus/pcie/domain.rs Removes the previous monolithic domain implementation (replaced by modules above).
anemone-kernel/src/device/bus/pcie/device.rs Refactors PCIe device types (bus vs endpoint+subbus) and adds BAR bookkeeping.
anemone-kernel/src/device/bus/pcie/bus.rs Reworks bus registration flow to run preinit → alloc_resources → postinit → probe.
anemone-kernel/src/device/bus/pcie/addr.rs Renames PCI function address type and improves formatting/docs.
anemone-kernel/crates/range-allocator/src/lib.rs Changes aligned allocation preconditions (currently breaks zero-align behavior).
anemone-kernel/crates/range-allocator/src/increasing.rs Adds free_size and adjusts alignment validation (currently breaks zero-align tests).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread anemone-kernel/crates/range-allocator/src/increasing.rs
Comment thread anemone-kernel/crates/range-allocator/src/increasing.rs
Comment thread anemone-kernel/src/device/bus/pcie/remap.rs
Comment thread anemone-kernel/src/driver/pcie_drivers/bus.rs
Comment thread anemone-kernel/src/driver/pcie_drivers/bus.rs Outdated
Comment thread anemone-kernel/src/device/bus/pcie/mod.rs Outdated
Comment thread anemone-kernel/crates/range-allocator/src/lib.rs
Comment thread anemone-kernel/src/driver/pcie_drivers/bus.rs
@EDGW EDGW merged commit c2e764c into main Apr 29, 2026
1 check passed
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.

3 participants