Skip to content

PCI: apple: honor T6050 cold-train bus-range and enable J775c SD reader - #3844

Merged
DjDeveloperr merged 2 commits into
mainfrom
feat/j775c-sdreader
Dec 1, 2026
Merged

DjDeveloperr merged 2 commits into
mainfrom
feat/j775c-sdreader

Conversation

@satchlj

@satchlj satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member

What: Teach apple_pcie_t6050_cold_train() to honor a port node's single-bus bus-range (instead of assuming start + 1 + port->idx) and enable the onboard Genesys GL9755 SDXC card reader on J775c (port01, bus 4) so Linux powers and trains it natively without bootloader changes.
Tested: J775c M5 Max Mac Studio at 2f458cfb4310 (built on main 539585d7a60e + required J775c display PRs #3682 and #3765, Stage 2 aura@main d8eb8ad4, default kernel command line): 2/2 clean boots + 15 s s2idle suspend/resume (rtcwake -m mem -s 15, rc=0), 00:01.0 -> 04:00.0 GL9755 (17a0:9755 rev 2) trained at 5 GT/s x1, dart_apcie1 (411000000.iommu, IOMMU group 20) + MSI active, sdhci-pci -> mmc0 (ADMA 64-bit), sibling ports (01:00 N1, 02:00 RTL8127, 03:00 ASM3142) and HDMI unaffected, 0 failed units, 0 new kernel errors.
Risk: two-way door · T6050 Macs using Linux PCIe cold-training (J775c enabled here; boards with contiguous bus-range or no bus-range keep existing behaviour).
Not yet: SD card media insert/read/write I/O (no card was inserted in the slot during this run; link training, DART/IOMMU attachment, MSI, sdhci-pci/mmc0 registration, and s2idle retention were verified on hardware).

Details
  1. PCI: apple: honor T6050 cold-train port bus-range (8825fd726988):
    On multi-port T6050 hosts where the bootloader brings up and renumbers sibling ports before Linux runs (for example, ports 0, 2, and 3 on buses 1..3), a port left down for Linux to cold-train can sit on a non-contiguous secondary bus (bus-range = <4 4> on J775c/J775d). Previously apple_pcie_t6050_cold_train() hardcoded bus = pcie->cfg->busr.start + 1 + port->idx, which programmed bus 2 for port01, colliding with port02 and routing to the wrong iommu-map / DART. Reading port->np's single-bus bus-range when present (validated against pcie->cfg->busr and checked for collisions against already-adopted ports in pcie->ports, keeping the start + 1 + port->idx fallback when absent) allows non-monotonic Linux cold-training cleanly on top of the existing no_reassign_bus bridge handling, and also helps multi-port T6050 boards such as J775d in arm64: dts: apple: t6050: share the SD card reader, add it to J714c, J716c, J716s and J775d #2291.

  2. arm64: dts: apple: t6050-j775c: enable SD card reader (2f458cfb4310):

    • Adds sd_pwr_en (0x19000000000000) as output 2 on smc_pcio.
    • Unreserves AP GPIO 81 (0x51, pci-bridge1 PERST#) in pinctrl_ap.
    • Enables dart_apcie1 with apple,manual-availability.
    • Adds phy-shared (0x417020000, size 0x4000) and post-init-providers = <&dart_apcie1> to pcie0 (matching t6050-k114-k116.dtsi where the bootloader leaves the shared PHY up with the other ports).
    • Enables port01 with pwren-gpios, reset-gpios, and the J775c ADT apcie-config and pcie-rc tunables.
Evidence
  • Test build: linux@main 539585d7a60e + J775c display PRs #3682 (bb01f44ff47e) and #3765 (510a838db7a7, required for J775c Stage 2 d8eb8ad4 FDT prep) + exact PR commits 8825fd726988 and 2f458cfb4310.
  • PCIe topology & link (lspci -tvnn, lspci -vv):
    -[0000:00]-+-00.0-[01]--+-00.0  Apple Inc. Device [106b:1900]
               |            +-00.1  Apple Inc. Device [106b:1902]
               |            \-00.2  Apple Inc. Device [106b:1903]
               +-01.0-[04]----00.0  Genesys Logic, Inc GL9755 SD Host Controller [17a0:9755]
               +-02.0-[02]----00.0  Realtek Semiconductor Co., Ltd. RTL8127 10GbE Controller [10ec:8127]
               \-03.0-[03]----00.0  ASMedia Technology Inc. ASM2142/ASM3142 USB 3.1 Host Controller [1b21:2142]
    
    00:01.0 (Bus: primary=00, secondary=04, subordinate=04): LnkSta: Speed 5GT/s, Width x1
    04:00.0 (17a0:9755 rev 02): Region 0: Memory at b80000000 [size=4K], IOMMU group: 20, MSI: Enable+ Count=1/1, Kernel driver in use: sdhci-pci
  • Kernel log excerpt:
    pcie-apple 1cb0000000.pcie: port 1: trained by Linux, the boot loader left it down
    pcie-apple 1cb0000000.pcie: port 1: RID 0400 -> SID 1, slot 1
    pcie-apple 1cb0000000.pcie: adopted port 1, endpoint 04:00
    apple-dart 411000000.iommu: params 9e313020 341100a3 2a2a0204 00011013, version 0204, 19 streams, ...
    sdhci-pci 0000:04:00.0: SDHCI controller found [17a0:9755] (rev 2)
    mmc0: SDHCI controller on PCI [0000:04:00.0] using ADMA 64-bit
    
  • Suspend/resume (rtcwake -m mem -s 15): rc=0, 16 s elapsed; post-resume 00:01.0 and 04:00.0 remain at 5GT/s x1, MSI enabled, mmc0 present, 0 failed units, 0 new dmesg -l err lines.
  • Static & host checks: scripts/checkpatch.pl --strict (0 errors, 0 warnings, 0 checks on both commits); tools/asahi/pcie-adopted-clkpm-tests.py and tools/asahi/pciec-policy-tests.py pass.

On multi-port T6050 hosts where the bootloader brings up and renumbers
sibling ports before Linux runs, a port left down for Linux to cold-train
may be described on a secondary bus other than start + 1 + port->idx
(for example, port 1 on bus 4 after ports 0, 2, and 3 take buses 1..3).

Hardcoding start + 1 + port->idx in apple_pcie_t6050_cold_train()
programs a colliding secondary bus and routes the port to the wrong
iommu-map entry and DART.

Read the port node's single-bus bus-range property when present, validate
it against the host bridge bus range, reject collisions with already
adopted ports, and keep the start + 1 + port->idx fallback when
bus-range is absent.

Signed-off-by: Satya Benson <satya@benson.earth>
Enable the onboard Genesys GL9755 SDXC card reader on PCIe port 1
(pci@1,0, bus 4) so pcie-apple powers and trains it natively in Linux
without requiring bootloader bring-up:

- Add sd_pwr_en (0x19000000000000) as output 2 on smc_pcio.
- Unreserve AP GPIO 81 (0x51, pci-bridge1 PERST#) in pinctrl_ap.
- Enable dart_apcie1 with apple,manual-availability.
- Add the shared PHY window (phy-shared, 0x417020000) and
  post-init-providers = <&dart_apcie1> to pcie0.
- Enable port01 with pwren-gpios, reset-gpios, and the J775c ADT
  apcie-config and pcie-rc tunables.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj requested review from a team as code owners December 1, 2026 22:33
@satchlj
satchlj requested review from LiamRay11 and maralcbr December 1, 2026 22:33
@github-actions github-actions Bot added area:bringup Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Merge readiness at 2f458cfb: ready to merge

Check Detail
CI at head ok 11 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at 2f458cfb
Conflicts ok none
PR text ok Risk: two-way · T6050 Macs using Linux PCIe cold-training (J775c enabled here; boards with contiguous bus-range or no bus-range keep existing behaviour).

Areas: area:bringup
Merge: gh pr merge 3844 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Checked the cold-train path and the J775c DT at 2f458cf. The port uses bus 4 for both secondary and subordinate numbering, matching its DART map. The driver validates the range and rejects a collision with an already adopted port before hardware writes. Existing T6050 cold-train DTs still select their original single bus. The J775c row covers two boots, card-reader enumeration and s2idle with the paired display fixes. Media I/O remains untested.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026
@DjDeveloperr
DjDeveloperr merged commit fd4bc33 into main Dec 1, 2026
13 checks passed
@DjDeveloperr
DjDeveloperr deleted the feat/j775c-sdreader branch December 1, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:bringup Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants