Skip to content

Multi-CMP BAR1 resize and nv_cmp_postbl parameter - #69

Closed
alexxy wants to merge 1 commit into
amoghmunikote:masterfrom
alexxy:fix/cmp-bar1-resize-postbl
Closed

alexxy wants to merge 1 commit into
amoghmunikote:masterfrom
alexxy:fix/cmp-bar1-resize-postbl

Conversation

@alexxy

@alexxy alexxy commented Nov 13, 2026 •

Copy link
Copy Markdown

Summary

BAR1 resize only unlocked the first CMP on multi-card servers — every later card kept its stock 256 MiB BAR1 and was unusable. Reworks the resize as one coordinated pass across all CMP probes and adds an nv_cmp_postbl module parameter.

Changes

  • BAR placement for CMP device IDs is now a coordinated pass across the probe of all CMPs instead of per-device resize: bounded barrier (deterministic, no first-come slot stealing), release each card's BAR1/BAR3 and prefetch windows to root, compute one 64 GiB-aligned slot per card in the largest host MEM window, claim top-down via pci_claim_resource, program bridge prefetch-window regs (1:1 mirror of pci_setup_bridge_mmio_pref) + reBAR ctrl + BAR regs, full rollback on failure. Engages only on CMP IDs, falls back to the stock path otherwise → single-card desktops unaffected.
  • Root causes (issue creation is disabled on this repo, so the analysis is inline):
    • 64 GiB BAR1 needs 64 GiB alignment; the alignment slack pbus_size_mem() reserves only accounts for the first card in a shared host-bridge aperture, so resize for later cards silently falls back to stock size.
    • Host apertures on this server are plain non-prefetch IORESOURCE_MEM (the [32-bit] tag in lspci is cosmetic); resize logic requiring IORESOURCE_PREFETCH never matches them.
    • Note: request_resource_conflict, pci_update_resource, pci_rebar_set_size are not exported to modules → direct register programming. for_each_pci_dev() is a bare while-macro; it breaks inside another while predicate.
  • Adds nv_cmp_postbl module parameter (default 1): the /etc/nvidia/cmp-postbl.disabled marker is unreadable inside the 615.x nv-probe kernel thread (os_open_readonly_file() returns a generic 0x59), so a parameter is the only working gate for the SEC2 post-BL payload. Can be split into a separate PR if preferred.

Testing

Live hardware, cold boot. dmesg shows NVRM: CMP BAR1: final size = 65536 MB for both GPUs; lspci shows 64 GiB prefetchable Region 1 per card, non-overlapping (apertures ≈256 GiB at root, ≈128 GiB per downstream port); nvidia-smi reports 65536 MiB per GPU. Reload/re-scan and rollback path exercised. Not tested on 10gb (no card) or with passthrough.

Hardware tested on (if applicable):

  • GPU variant: 2× CMP 170HX 8 GB (10de:20c2)
  • PCIe slot / host: Supermicro X10DRG-H — GPU behind PCIe switch 80:03.0 → 83:00.0 (USP) → 84:08.0 / 84:10.0 (DSP, x4) → 85:00.0 / 86:00.0
  • Kernel / OS: 7.3.4-gentoo-dist, Gentoo Linux

bar1-resize-unlock v6.2: bypass stock pci_resize_resource on CMPs; one
coordinated pass (bounded barrier across probes) releases CMP BAR1/BAR3
and prefetch windows, places a single 128 GiB window per card inside the
largest host MEM aperture, claims top-down and writes bridge/reBAR/BAR
registers directly, with full rollback on failure. Fixes the second
card's resize on multi-CMP servers (pbus_size_mem alignment slack; host
apertures never carry IORESOURCE_PREFETCH). Adds the nv_cmp_postbl
module parameter (default 1) as the gate for the SEC2 post-BL timing
path, read by the sec2-postbl gate - the /etc/nvidia/cmp-postbl.disabled
marker cannot load in 615.x kthread context (os_open_readonly_file
returns generic 0x59).
@alexxy

alexxy commented Nov 13, 2026

Copy link
Copy Markdown
Author

Actually this is the same multi-card failure as in #59, but it fixes the other half of that problem too.

#59 correctly diagnosed the 615.x parallel-probe race (PROBE_PREFER_ASYNCHRONOUS + per-GPU kthreads; two cards doing release-and-reassign on shared bridges at once → one ends at final size = 0 MB). Its mutex removes the race, but, as the PR itself notes, not the size: with cards serialized, card A cannot grow the shared bridge window while card B's BARs still sit inside it — so both cards stay at the stock 64 MB BAR1. It fixes the dead card, not the BAR size.

The coordinated pass here plans placement once instead of serializing resize attempts:

  • a barrier across the probe of all CMPs — no interleaving and no first-come slot stealing, the 0 MB failure mode is structurally impossible;
  • release BAR1/BAR3 and bridge prefetch windows for all cards first, then place every 64 GiB-aligned slot into the single largest free host MEM window, claim top-down, program bridge + reBAR + BAR regs;
  • accepts non-prefetch host apertures — on this Supermicro the host windows are plain IORESOURCE_MEM ([32-bit] in lspci output is cosmetic), which stock resize never matches;
  • full rollback on failure; engages only on CMP device IDs, everything else falls back to the stock path, so single-card desktops are unaffected.

Result on the same topology class (2× 8gb CMP 170HX behind a PCIe switch): both cards at final size = 65536 MB — not 64 MB — with non-overlapping 64 GiB Region 1s and apertures ~256 GiB at root / ~128 GiB per downstream port.

Credit to @cibernox — the race analysis in #59 matches what I reproduced here.

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.

2 participants