Files
RedBear-OS/local/recipes/system/redbear-quirks/source/quirks.d/05-pcie-quirks.toml
T
vasilito 86902d4819 quirks: implement R0-R5 — data-driven PCI/USB/DMI bitmask system
Foundational data-driven hardware-quirk system with all entries through
Phase R5. Source of truth: Linux 7.1 DECLARE_PCI_FIXUP_* and PCI_DEV_FLAGS_*
conventions. Targets AMD64 bare metal, QEMU, and modern peripherals.

Code (redox-driver-sys/src/quirks/):
- PciQuirkFlags: 46 bits used (0-45), 18 reserved
- UsbQuirkFlags + XhciControllerQuirkFlags tables
- PciConfigWriter trait + QuirkAction enum (7 variants)
- 14 named callbacks (intel_no_aspm_l0s, amd_ide_class_fix,
  ht_enable_msi_mapping, p64h2_1k_io, intel_ntb_bar_fix, 7 DMA-alias
  callbacks, amd_fe_gate_ordering, amd_8131_mmrbc)
- lookup_pci_quirks_full, lookup_pci_quirks, lookup_usb_quirks,
  lookup_xhci_controller_quirks, lookup_dmi_rules
- find_standard_capability for PCI cap walks
- TOML loader with [[pci_quirk]] / [[usb_quirk]] / [[dmi_rule]] sections
- 75 tests pass (mod.rs + toml_loader + dmi + others)

Phase R5 adds (2026-06-07):
- 10 new flag bits (36-45): BROKEN_INTX_MASKING, NO_PME, PCI_PROBLEM_*,
  PCI_AGP_FAIL, BUS_NO_MMRBC
- 2 new callbacks: cb_amd_fe_gate_ordering (AMD-762 two-register write),
  cb_amd_8131_mmrbc (rev-gated < 0x12, sets BUS_NO_MMRBC)
- Inline ClearBit/SetBit actions for Mellanox, Cyrix, Intel, VIA
- 18 new Phase R5 tests (10 mod.rs + 8 toml_loader)

TOML (10 files, 244 entries in 07-pci-final-quirks.toml total):
  00-core.toml                  (41)
  05-pcie-quirks.toml           (52)
  06-pci-header-quirks.toml     (37)
  07-pci-final-quirks.toml      (64)  — R5 DECLARE_PCI_FIXUP_FINAL
  10-gpu.toml                   (33)
  15-audio.toml                  (7)

Verified: 38 distinct flag names used, 46 defined, 0 undefined references.

Docs: local/docs/QUIRKS-SYSTEM.md — R0-R5 implementation reports (2424 lines)
2026-06-07 09:18:40 +03:00

350 lines
7.4 KiB
TOML

# New PCIe quirk entries introduced in Phase R2 (2026-06-07).
# Source: Linux 7.1 drivers/pci/quirks.c + include/linux/pci.h
#
# Flag bit map (see PciQuirkFlags in redox-driver-sys):
# bit 22: NO_FLR (no-resource-reloc root ports)
# bit 23: NO_EXT_TAGS
# bit 24: NO_RELAXED_ORDERING
# bit 25: MPSS_256
# bit 26: ROM_BAR_OVERLAP
# bit 27: NO_ATS (AMD GPU ATS harvest)
# bit 28: NO_BUS_RESET
#
# NO_FLR entries (9 device IDs) live in 00-core.toml.
# NO_ATS entries (14 device IDs) live in 10-gpu.toml.
# ============================================================================
# NO_EXT_TAGS — disables PCIe Extended Tags on the host bridge
# Linux: quirk_no_ext_tags (drivers/pci/quirks.c)
# Reason: these devices claim to support Extended Tags but actually
# mis-handle TLP tags, which can corrupt DMA transactions.
# ============================================================================
# 3ware 9650/9690 SAS/SATA controllers
[[pci_quirk]]
vendor = 0x13C1
device = 0x1004
flags = ["no_ext_tags"]
[[pci_quirk]]
vendor = 0x13C1
device = 0x1005
flags = ["no_ext_tags"]
# ServerWorks (Broadcom) PCI-X-to-PCI-X bridges
[[pci_quirk]]
vendor = 0x1166
device = 0x0132
flags = ["no_ext_tags"]
[[pci_quirk]]
vendor = 0x1166
device = 0x0140
flags = ["no_ext_tags"]
[[pci_quirk]]
vendor = 0x1166
device = 0x0141
flags = ["no_ext_tags"]
[[pci_quirk]]
vendor = 0x1166
device = 0x0142
flags = ["no_ext_tags"]
[[pci_quirk]]
vendor = 0x1166
device = 0x0144
flags = ["no_ext_tags"]
[[pci_quirk]]
vendor = 0x1166
device = 0x0420
flags = ["no_ext_tags"]
[[pci_quirk]]
vendor = 0x1166
device = 0x0422
flags = ["no_ext_tags"]
# ============================================================================
# NO_RELAXED_ORDERING — disables PCIe Relaxed Ordering on Root Port
# Linux: quirk_relaxedordering_disable (drivers/pci/quirks.c)
# Reason: Intel Broadwell/Haswell PCIe root ports have a Flow Control
# Credit erratum that causes Completion TLPs to be lost when Relaxed
# Ordering is enabled on downstream devices. The quirk sets the flag
# on the root port; pci_configure_relaxed_ordering() then walks the
# bus and clears PCI_EXP_DEVCTL_RELAX_EN (0x0010) on each endpoint.
# Class: PCI_CLASS_NOT_DEFINED (0x000000), class_mask 0xFF0000
# ============================================================================
# Intel 0x6f01-0x6f0e — Broadwell/Haswell microarchitecture
[[pci_quirk]]
vendor = 0x8086
device = 0x6F01
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F02
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F03
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F04
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F05
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F06
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F07
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F08
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F09
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F0A
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F0B
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F0C
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F0D
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x6F0E
class = 0x000000
flags = ["no_relaxed_ordering"]
# Intel 0x2f01-0x2f0e — same erratum
[[pci_quirk]]
vendor = 0x8086
device = 0x2F01
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F02
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F03
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F04
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F05
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F06
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F07
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F08
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F09
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F0A
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F0B
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F0C
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F0D
class = 0x000000
flags = ["no_relaxed_ordering"]
[[pci_quirk]]
vendor = 0x8086
device = 0x2F0E
class = 0x000000
flags = ["no_relaxed_ordering"]
# ============================================================================
# MPSS_256 — limits PCIe Max Payload Size to 256 bytes
# Linux: fixup_mpss_256 (drivers/pci/quirks.c)
# Reason: SolarFlare/ASMedia controllers advertise support for >256 byte
# MPS but actually corrupt data above 256. The fix caps pcie_mpss = 1
# (256 bytes) without rewriting hardware registers.
# ============================================================================
# ASMedia ASM1062 SATA controller
[[pci_quirk]]
vendor = 0x1B21
device = 0x0612
flags = ["mpss_256"]
# Solarflare SFN4000A/SFN4000B 10GbE
[[pci_quirk]]
vendor = 0x1924
device = 0x0703
flags = ["mpss_256"]
[[pci_quirk]]
vendor = 0x1924
device = 0x6703
flags = ["mpss_256"]
[[pci_quirk]]
vendor = 0x1924
device = 0x0710
flags = ["mpss_256"]
# ============================================================================
# NO_BUS_RESET — disables PCI secondary bus reset
# Linux: quirk_no_bus_reset + quirk_nvidia_no_bus_reset (drivers/pci/quirks.c)
# Reason: these devices can hang or fail to recover from a downstream
# bus reset. The check is in pci_parent_bus_reset() and pci_bus_resettable().
# ============================================================================
# Atheros AR9xxx/QCA988x Wi-Fi — link down on AER systems after SBR
[[pci_quirk]]
vendor = 0x168C
device = 0x0030
flags = ["no_bus_reset"]
[[pci_quirk]]
vendor = 0x168C
device = 0x0032
flags = ["no_bus_reset"]
[[pci_quirk]]
vendor = 0x168C
device = 0x0033
flags = ["no_bus_reset"]
[[pci_quirk]]
vendor = 0x168C
device = 0x0034
flags = ["no_bus_reset"]
[[pci_quirk]]
vendor = 0x168C
device = 0x003C
flags = ["no_bus_reset"]
[[pci_quirk]]
vendor = 0x168C
device = 0x003E
flags = ["no_bus_reset"]
# NVIDIA GPUs where (device & 0xffc0) == 0x2340 — broader pattern
# Listed as first/last of the range for documentation; full range
# matching would require the QuirkAction mechanism (Phase R4) for
# mask-based device-ID matching.
[[pci_quirk]]
vendor = 0x10DE
device = 0x22CE
flags = ["no_bus_reset"]
[[pci_quirk]]
vendor = 0x10DE
device = 0x22D0
flags = ["no_bus_reset"]
# Cavium CN8xxx root port
[[pci_quirk]]
vendor = 0x177D
device = 0xA100
flags = ["no_bus_reset"]
# TI KeyStone C667X
[[pci_quirk]]
vendor = 0x104C
device = 0xB005
flags = ["no_bus_reset"]
# ASMedia ASM1164 — bus reset is broken
[[pci_quirk]]
vendor = 0x1B21
device = 0x1164
flags = ["no_bus_reset"]