Files
RedBear-OS/local/recipes/system/redbear-quirks/source/quirks.d/07-pci-final-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

473 lines
12 KiB
TOML

# Phase R5 (2026-06-07) — PCI Final Fixup entries mined from Linux 7.1
# Source: Linux 7.1 drivers/pci/quirks.c, DECLARE_PCI_FIXUP_FINAL() macros
#
# Flag bit map (see PciQuirkFlags in redox-driver-sys):
# bit 36: BROKEN_INTX_MASKING (quirk_broken_intx_masking)
# bit 37: NO_PME (pci_fixup_no_d0_pme, pci_fixup_no_msi_no_pme)
# bit 38: PCI_PROBLEM_FAIL (pci_pci_problems PCIPCI_FAIL)
# bit 39: PCI_PROBLEM_TRITON (pci_pci_problems PCIPCI_TRITON)
# bit 40: PCI_PROBLEM_NATOMA (pci_pci_problems PCIPCI_NATOMA)
# bit 41: PCI_PROBLEM_VIAETBF (pci_pci_problems PCIPCI_VIAETBF)
# bit 42: PCI_PROBLEM_VSFX (pci_pci_problems PCIPCI_VSFX)
# bit 43: PCI_PROBLEM_ALIMAGIK (pci_pci_problems PCIPCI_ALIMAGIK)
# bit 44: PCI_AGP_FAIL (pci_pci_problems PCIAGP_FAIL)
# bit 45: BUS_NO_MMRBC (quirk_amd_8131_mmrbc; subordinate bus flag)
#
# This file targets the 50 most AMD64-relevant FINAL fixup entries
# out of 233 in Linux 7.1. Deferred entries (NEEDS_INFRA / PM /
# device-tree) are listed in the doc/QUIRKS-SYSTEM.md Phase R5 report.
#
# Categories:
# 1. PCI bridge aliasing and forwarding quirks (config-RMW)
# 2. BAR sizing and resource allocation fixes (callbacks)
# 3. DMA address mask / MSI disable quirks (flag-setters)
# 4. Device-specific post-enumeration workarounds
# ============================================================================
# Category 1 — PCI bridge aliasing and forwarding (config-space RMW)
#
# These handlers do a single config-space read-modify-write, so they are
# expressed directly as inline `QuirkAction::ClearBit` / `SetBit` actions.
# No callback is needed.
# ============================================================================
# Mellanox Tavor (T2) — pci_disable_parity.
# Linux quirk clears PCI_COMMAND_PARITY (bit 6 of offset 0x04) because
# the device raises spurious parity errors that flood the AER log.
[[pci_quirk]]
vendor = 0x15b3
device = 0x1007
flags = []
action = { kind = "clear_bit", offset = 0x04, width = "word", bit = 6 }
# Mellanox Tavor Bridge
[[pci_quirk]]
vendor = 0x15b3
device = 0x1008
flags = []
action = { kind = "clear_bit", offset = 0x04, width = "word", bit = 6 }
# Cyrix PCI Master — quirk_mediagx_master.
# Linux clears bit 1 of byte 0x41 to disable bus-master retries that
# hang the MediaGX northbridge. rev-gated; only applies to rev 0x00.
[[pci_quirk]]
vendor = 0x110a
device = 0x0001
revision_lo = 0x00
revision_hi = 0x00
flags = []
action = { kind = "clear_bit", offset = 0x41, width = "byte", bit = 1 }
# Intel 82454NX PXB — quirk_disable_pxb.
# Linux clears bit 6 of word 0x40 only for rev 0x04 (erratum 3).
# Other revisions of the same device ID do not need the fixup.
[[pci_quirk]]
vendor = 0x8086
device = 0x84cb
revision_lo = 0x04
revision_hi = 0x04
flags = []
action = { kind = "clear_bit", offset = 0x40, width = "word", bit = 6 }
# VIA VT8237 — quirk_via_vt8237_bypass_apic_deassert.
# Linux sets bit 3 of byte 0x5B to bypass APIC de-assert, which is
# required for the integrated APIC to function under IO-APIC mode.
[[pci_quirk]]
vendor = 0x1106
device = 0x3227
flags = []
action = { kind = "set_bit", offset = 0x5B, width = "byte", bit = 3 }
# ============================================================================
# Category 2 — BAR sizing and resource allocation fixes (callbacks)
#
# These require callbacks because they are multi-register writes
# (AMD FE Gate) or rev-gated (AMD 8131 MMRBC).
# ============================================================================
# AMD-762 northbridge — quirk_amd_ordering.
# Enables posted-write ordering via two config-space writes (0x4C |= 6,
# 0x84 |= 0x800000). Without this fix, posted writes can complete out
# of order, corrupting scatter-gather DMA buffers.
[[pci_quirk]]
vendor = 0x1022
device = 0x700C
flags = []
action = { kind = "callback", name = "amd_fe_gate_ordering" }
# AMD 8131 PCI-X bridge — quirk_amd_8131_mmrbc.
# Rev ≤ 0x12 has a PCI-X MMRBC bug. The Linux fix sets
# PCI_BUS_FLAGS_NO_MMRBC on the subordinate bus. Red Bear has no bus
# property type, so we model it as a device-level `bus_no_mmrbc` flag
# that the PCI scheme daemon checks before honoring MMRBC.
[[pci_quirk]]
vendor = 0x1022
device = 0x7450
revision_lo = 0x00
revision_hi = 0x12
flags = ["bus_no_mmrbc"]
action = { kind = "callback", name = "amd_8131_mmrbc" }
# ============================================================================
# Category 3 — DMA / MSI disable quirks (flag-setters via existing NO_MSI)
#
# These handlers only set a dev->no_msi flag, so they translate to the
# existing `no_msi` PciQuirkFlags bit.
# ============================================================================
# ATI SBx00 southbridge (6 device IDs) — quirk_no_msi.
# SBx00 chipsets have a known MSI hardware defect; Linux forces
# legacy IRQ for the SMBus/audio functions.
[[pci_quirk]]
vendor = 0x1002
device = 0x4386
flags = ["no_msi"]
[[pci_quirk]]
vendor = 0x1002
device = 0x4387
flags = ["no_msi"]
[[pci_quirk]]
vendor = 0x1002
device = 0x4388
flags = ["no_msi"]
[[pci_quirk]]
vendor = 0x1002
device = 0x4389
flags = ["no_msi"]
[[pci_quirk]]
vendor = 0x1002
device = 0x438a
flags = ["no_msi"]
[[pci_quirk]]
vendor = 0x1002
device = 0x438b
flags = ["no_msi"]
# Intel E7520/E7320/E7525 Memory Controller Hubs — quirk_pcie_mch.
# These MCHs have DMA alias issues with the IOMMU; Linux disables
# MSI as a side-effect of the workaround.
[[pci_quirk]]
vendor = 0x8086
device = 0x3590
flags = ["no_msi"]
[[pci_quirk]]
vendor = 0x8086
device = 0x3592
flags = ["no_msi"]
[[pci_quirk]]
vendor = 0x8086
device = 0x359e
flags = ["no_msi"]
# ============================================================================
# Category 4 — Device-specific post-enumeration workarounds
# ============================================================================
# --- NO_ATS: AMD harvest / dGPUs that cannot use Address Translation ---
# AMD Stoney Ridge dGPU
[[pci_quirk]]
vendor = 0x1002
device = 0x98e4
flags = ["no_ats"]
# AMD Iceland dGPU
[[pci_quirk]]
vendor = 0x1002
device = 0x6900
flags = ["no_ats"]
# AMD Navi10 (RX 5000 series) — five device IDs
[[pci_quirk]]
vendor = 0x1002
device = 0x7310
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x1002
device = 0x7312
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x1002
device = 0x7318
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x1002
device = 0x7319
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x1002
device = 0x731a
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x1002
device = 0x731b
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x1002
device = 0x731e
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x1002
device = 0x731f
flags = ["no_ats"]
# AMD Navi14 (RX 5500 series)
[[pci_quirk]]
vendor = 0x1002
device = 0x7340
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x1002
device = 0x7341
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x1002
device = 0x7347
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x1002
device = 0x734f
flags = ["no_ats"]
# AMD Raven Ridge dGPU
[[pci_quirk]]
vendor = 0x1002
device = 0x15d8
flags = ["no_ats"]
# Intel IPU E2000 — quirk_intel_e2000_no_ats.
# Rev < 0x20 of the IPU has broken ATS support. Linux disables ATS
# before driver init; the rev gate prevents the fix from triggering
# on later silicon that has working ATS.
[[pci_quirk]]
vendor = 0x8086
device = 0x1451
revision_lo = 0x00
revision_hi = 0x1f
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x8086
device = 0x1452
revision_lo = 0x00
revision_hi = 0x1f
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x8086
device = 0x1453
revision_lo = 0x00
revision_hi = 0x1f
flags = ["no_ats"]
[[pci_quirk]]
vendor = 0x8086
device = 0x1454
revision_lo = 0x00
revision_hi = 0x1f
flags = ["no_ats"]
# --- BROKEN_INTX_MASKING: devices that advertise MSI masking but the
# bit is non-functional. Driver must fall back to MSI-X.
# Chelsio T3 1GbE
[[pci_quirk]]
vendor = 0x1425
device = 0x0030
flags = ["broken_intx_masking"]
# Ralink RT2800 802.11n
[[pci_quirk]]
vendor = 0x1814
device = 0x0601
flags = ["broken_intx_masking"]
# Ceton InfiniTV4
[[pci_quirk]]
vendor = 0x1b7c
device = 0x0004
flags = ["broken_intx_masking"]
# Creative SB20K2
[[pci_quirk]]
vendor = 0x1102
device = 0x000B
flags = ["broken_intx_masking"]
# Realtek RTL8169
[[pci_quirk]]
vendor = 0x10ec
device = 0x8169
flags = ["broken_intx_masking"]
# Intel i40e XL710/X710 family (representative subset of 16 IDs)
[[pci_quirk]]
vendor = 0x8086
device = 0x1572
flags = ["broken_intx_masking"]
[[pci_quirk]]
vendor = 0x8086
device = 0x1574
flags = ["broken_intx_masking"]
[[pci_quirk]]
vendor = 0x8086
device = 0x1580
flags = ["broken_intx_masking"]
[[pci_quirk]]
vendor = 0x8086
device = 0x37d2
flags = ["broken_intx_masking"]
# --- NO_PME: devices that advertise PME from D0 but cannot actually wake ---
# Asmedia ASM2142 USB 3.1 controller — pci_fixup_no_d0_pme.
# The controller's D0 PME state is broken; clearing it prevents
# spurious wake events.
[[pci_quirk]]
vendor = 0x1b21
device = 0x2142
flags = ["no_pme"]
# Pericom PI7C9X — pci_fixup_no_msi_no_pme.
# Both MSI and PME are broken; the driver falls back to legacy IRQ
# and ignores D0 wake.
[[pci_quirk]]
vendor = 0x12D8
device = 0x400e
flags = ["no_msi", "no_pme"]
[[pci_quirk]]
vendor = 0x12D8
device = 0x400f
flags = ["no_msi", "no_pme"]
# ============================================================================
# Category 5 — pci_pci_problems global flags
#
# Linux's pci_pci_problems is a process-global u32 bitmask. Red Bear
# models each problem as an individual PciQuirkFlags bit so consumers
# can query them like any other quirk flag.
# ============================================================================
# PCI_PROBLEM_FAIL — SI 5597/496 host bridges. The PCI-PCI bridge
# emulation is broken; Linux falls back to conservative timing.
[[pci_quirk]]
vendor = 0x1039
device = 0x5597
flags = ["pci_problem_fail"]
[[pci_quirk]]
vendor = 0x1039
device = 0x0496
flags = ["pci_problem_fail"]
# PCI_AGP_FAIL — AMD 8151_0 only when rev 0x13. AGP transactions
# corrupt memory on this specific stepping.
[[pci_quirk]]
vendor = 0x1022
device = 0x7454
revision_lo = 0x13
revision_hi = 0x13
flags = ["pci_agp_fail"]
# PCI_PROBLEM_TRITON — Intel 82437/82437VX/82439/82439TX Triton.
# Triton northbridges need extra PCI-PCI bridge turn-around cycles.
[[pci_quirk]]
vendor = 0x8086
device = 0x122d
flags = ["pci_problem_triton"]
[[pci_quirk]]
vendor = 0x8086
device = 0x7030
flags = ["pci_problem_triton"]
[[pci_quirk]]
vendor = 0x8086
device = 0x1250
flags = ["pci_problem_triton"]
[[pci_quirk]]
vendor = 0x8086
device = 0x7100
flags = ["pci_problem_triton"]
# PCI_PROBLEM_VIAETBF — VIA 82C597_0.
# Errata in the ETBF (Early Transaction Buffer) cause livelocks.
[[pci_quirk]]
vendor = 0x1106
device = 0x0597
flags = ["pci_problem_viaetbf"]
# PCI_PROBLEM_VSFX — VIA 82C576.
# The VSFX (Video Side FX) bridge has broken posted-write ordering.
[[pci_quirk]]
vendor = 0x1106
device = 0x0576
flags = ["pci_problem_vsfx"]
# PCI_PROBLEM_ALIMAGIK — ALi M1647 / M1651.
# The Aladdin V/V+ northbridges combine ALi-ali-MAGiK and Triton
# problems; both bit patterns are needed to disable all fast paths.
[[pci_quirk]]
vendor = 0x10b9
device = 0x1647
flags = ["pci_problem_alimagik"]
[[pci_quirk]]
vendor = 0x10b9
device = 0x1651
flags = ["pci_problem_alimagik"]
# PCI_PROBLEM_NATOMA — Intel 82441 / 82443LX / 82443BX.
# The Natoma core needs special PCI-PCI bridge handling.
[[pci_quirk]]
vendor = 0x8086
device = 0x1237
flags = ["pci_problem_natoma"]
[[pci_quirk]]
vendor = 0x8086
device = 0x7180
flags = ["pci_problem_natoma"]
[[pci_quirk]]
vendor = 0x8086
device = 0x7181
flags = ["pci_problem_natoma"]
[[pci_quirk]]
vendor = 0x8086
device = 0x7190
flags = ["pci_problem_natoma"]
[[pci_quirk]]
vendor = 0x8086
device = 0x7191
flags = ["pci_problem_natoma"]
[[pci_quirk]]
vendor = 0x8086
device = 0x7192
flags = ["pci_problem_natoma"]