Repository navigation
arm: apple: bring PCIe up only when USB is started at boot - #65
Draft
RyanTheTide wants to merge 2 commits into
Draft
RyanTheTide wants to merge 2 commits into
RyanTheTide wants to merge 2 commits into
Conversation
Loading the environment from a file system on NVMe enumerated every PCI bus first, so that a PCI-attached controller is found. With CONFIG_NVME_PCI off no NVMe controller can be on PCI, and the enumeration only brings up buses that have nothing to do with the environment. On Apple Silicon, where NVMe is a platform device, this trained the links of every PCIe port (100 ms after PERST# each, plus the link wait) while loading uboot.env. Signed-off-by: Ryan Murray <[email protected]>
PCI_INIT_R enumerated every PCIe port after relocation on every boot. Each enabled port costs 100 ms after PERST# deassertion plus the wait for its link, so the Wi-Fi and SD card ports of a 14"/16" MacBook Pro cost U-Boot a few hundred milliseconds, and the OS resets every port again anyway. The only PCIe devices U-Boot drives on these machines are the PCIe xHCI controllers behind the USB-A ports of machines without a built-in keyboard, and USB is started at boot only there (preboot "usb start", see apple_typec_late_init()). Drop PCI_INIT_R and enumerate PCI in board_late_init() when preboot starts USB, which keeps the desktops as they are and also honours a saved environment that starts USB. "pci enum" still works by hand. Signed-off-by: Ryan Murray <[email protected]>
Contributor
Author
|
Looks good; approve once the laptop and desktop rows below have run. What I checked:
This changes when PCIe trains on every Mac, so it needs a run before merge. HW row: aura-try U-Boot trials on this head (stacked on #58 is fine), 3 boots each:
All with 0 AVC, 0 failed units and no new kernel errors. Assisted-by: LLM (Claude:Opus 5.5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On an M1 Pro with #58,
board_init_r()still takes 0.62 s, and bootstage marks after every initcall put all but 36 ms of it in one initcall:initr_env()(554 ms; this config has no MMC/NAND/OneNAND between it andefi_init_early()).env_fat_load()callspci_init()before it scans NVMe wheneverCONFIG_PCIis on. On Apple Silicon NVMe is a platform device, so this only brings up every PCIe port. Each enabled port costs a fixed 100 ms after PERST# (apple_pcie_setup_port()), then a ready poll and a link poll of up to 100 ms. The 14"/16" MacBook Pro has two such ports (Wi-Fi and the SD card reader).PCI_INIT_Rwould bring them up a moment later anyway. Nothing in U-Boot uses them on these machines, and the OS resets every port again.Change
CONFIG_NVME_PCI, the only case where an NVMe controller can be on PCI.PCI_INIT_Rfromapple_m1_defconfig.board_late_init()runspci_init()only if preboot starts USB. The PCIe xHCI behind the USB-A ports of machines without a built-in keyboard is the only PCIe device U-Boot drives here, and preboot keepsusb startexactly there (apple_typec_late_init()), or wherever a saved environment asks for it.pci enumstill works by hand.Desktops keep today's behaviour: PCIe still comes up before preboot runs
usb start. Laptops skip it. The A18 Pro already skips PCIe in the driver.Testing
apple_m1_defconfig, GCC 16.1 aarch64: builds clean. Checked alone on aurora-wip and stacked on arm: apple: turn the caches on before relocation #58;CONFIG_PCI_INIT_Ris off in the resulting.config. checkpatch clean.Still to run
aura-try U-Boot trials (Stage 2 with only the U-Boot payload swapped, trial guard, dead-man), stacked on #58, 3 boots each:
board_init_r->main_loopdrops from 0.62 s by 0.2 to 0.4 s.In Linux on each trial boot: Wi-Fi associates, Bluetooth is present, the SD reader enumerates (M1 Pro), and there are no pcie-apple errors, 0 failed units and 0 AVC. A desktop row (Mac mini: USB-A keyboard at the U-Boot prompt) is owed before merge.
What else is in the 554 ms
After PCIe,
initr_env()also cold-boots the ANS (the boot loader resets it before handing over on pre-M4 machines), enables the controller, identifies the namespaces, scans the GPT, finds the ESP (FAT mount,fs_exists()), and readsuboot.env. An instrumented build with marks inside those steps (and an NVMe command counter) is part of the trial set, to size each piece before touching any of them. No fixed delays are on that path in the source: the RTKit handshake waits on mailbox messages, and the ready polls (ANS_BOOT_STATUS, CSTS.RDY) poll registers.