Repository navigation
PCI: apple: power the J604's empty SD card reader down, as macOS does - #1998
IronsideXXVI wants to merge 9 commits into
Conversation
0f41e6b to
4be12fb
Compare
|
Rebased onto integration/aurora c92ed85. One conflict, the include lines in pcie-apple.c; the changed lines of all nine commits are identical to what runs on the J604 in linux-aurora 1.1125. All 137 Apple DTBs build with 0 warnings and the 136 other than t8132-j604 are byte-identical to the base; pcie-apple.o and gpio-macsmc.o build with W=1 and 0 warnings; the two host tests pass (8 and 10 cases). Back to draft: the series still has two module parameters (t8132_sd_port_off, t8132_sd_restore_root). The next revision drops them and keeps the shipped behaviour as the only one. |
8d43691 to
3bce9ab
Compare
|
Reworked with no module parameters. Rebased onto df62a8c. Each commit builds with W=1 and no warnings. The 137 Apple DTBs other than the J604's are byte-identical to the base. The host test now checks the decision without a parameter (6 cases, 3 mutations caught). The details are in the description. Still not tested: a card inserted while the port is off. I'll post the result here. Marking this ready for review. |
3bce9ab to
9345589
Compare
|
The host-tests failure on 3bce9ab was mine, two things:
Both are folded into the commits that caused them. The code is unchanged. 9345589 is green on all checks. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Thanks for dropping both parameters and putting the DART hold ahead of the DT commit; the series is much easier to follow now.
Blocking:
- Binding. In
apple,pcie.yaml, the newcard-detect-gpiosis inserted betweenclkreq-gpios' description and itsmaxItems: 1. After the patch,clkreq-gpioshas nomaxItemsandcard-detect-gpioshas taken it. Each needs its ownmaxItems: 1. - The main path hasn't run. A card inserted while the port is off is still untested, and the J604 DT commit turns the power-down on. Before merge, please post a row:
- insert a card with the port off;
- read and write a file;
- remove it and insert it again;
- one insert across a deep sleep.
- Inert on our tree. On Aurora's J604 tree,
port02is still disabled under the managed contract (see my note on #1962). As merged, only the SMC interrupt controller would be live, and the PCI side would never run. That ties this to the #1962 decision, and I'd sequence it after that rather than merge code our own tree doesn't exercise.
Smaller:
APPLE_PCIE_T8132_EXP 0x70hard-codes the root port's PCIe capability offset for a log line.pcie_capability_read_word()on the held root port (orpci_find_capability()) avoids both the constant and the SoC name in generic code.
The gpio-macsmc interrupt support looks right to me:
- it's only enabled for a node with
interrupt-controller; - the lines are nested threaded IRQs fed from the SMC notifier chain;
- mode and enable are written in
bus_sync_unlock; - the ack comes after the handler.
|
Thanks. I'll fix the binding so |
The SMC can watch an input and report its configured level or edge as an event of type 0x7202, with the line number in bits 15:8; it holds the next event for that line until the line is acknowledged with command 5. The driver defined the commands (IRQ enable 4, ack 5, mode 6) but never used them, so no SMC input could be an interrupt. The earlier Asahi Linux version of this driver had the support; this brings it back in the current driver's shape: - Only a node marked interrupt-controller gets an irqchip, so no other Mac changes. Lines whose IRQ mode reads back at probe are the ones that can interrupt. - Events come from the SMC's notifier chain in process context, so the lines are nested threaded interrupts. Every handled event is acknowledged on its own key, whether or not a consumer mapped the line, or the SMC would hold the next one. - The irqchip callbacks only record the wanted mode and enable; the bus unlock writes each of them only when it differs from what the SMC was last given, and a failed write is retried at the next unlock. The earlier version copied the mode the wrong way after a write, which wrote it again at every unlock. - The chip is immutable and uses the gpiolib resource helpers. tools/asahi/macsmc-gpio-irq-tests.py builds the event handler and the irqchip callbacks from this file against a fixture that records every SMC write and nested interrupt (8 cases), and kills three mutations: no ack, the earlier mode bookkeeping, and an unchecked event type. Signed-off-by: Dylan Ironside <[email protected]>
The SMC reports the inputs it watches as events, one line number per event, and holds the next one for a line until it is acknowledged. Let a node offer them as interrupts, with two cells (line, type). The Apple device tree of the MacBook Pro 14-inch (M4, J604) describes the SD reader's card detect this way: the reader node's interrupt-parent is the SMC PMU and its interrupt is line 9, so the card can be detected while the reader's PCIe port is powered down. Signed-off-by: Dylan Ironside <[email protected]>
A card reader behind a root port can have its card detect wired to an input that still reports while the reader is powered down. Describe it on the port as card-detect-gpios, so the port can be powered down while the slot is empty. The MacBook Pro 14-inch (M4, J604) wires its SD reader's card detect to an SMC input this way. Signed-off-by: Dylan Ironside <[email protected]>
9345589 to
1ea0914
Compare
|
Pushed 1ea0914, rebased onto 5b596e6. |
|
Blockers: 3.
The gpio-macsmc part and the binding fix were covered in the earlier review; I have nothing to add there. HW row: J604 on this head with the J604 DT commit, default command line: boot with the slot empty (reader down, no DART fault, 10 boots); insert a card with the port off, read and write a file, remove and reinsert; one insert across a deep sleep; one Assisted-by: LLM (Claude:Opus 5.5) |
|
Agreed on all four. This is more than I can fold into a quick respin, so here is what is changing; the push follows with the HW row.
The HW row will be on the new head over |
|
This still applies cleanly to the current integration/aurora tip 110861f, and nothing equivalent is on the tip: there's no card-detect handling in pcie-apple.c and no SMC GPIO interrupt support. The head 1ea0914 predates the respin agreed on 11-21. That respin removes the 10 s boot timer in favour of a decision at port setup, and fixes the teardown order of sd_work and the card-detect IRQ against pci_remove_root_bus(). The card rows are also still open: insert with the port off, read and write, remove and reinsert, one insert across a deep sleep. As agreed in review, this follows #1962, which is still a draft. Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, no warnings in the files it touches; CHECK_DTBS over every Apple DTB: no new warnings against the tip. Host tests (tools/asahi/run-host-tests.py --only) on 110861f plus this change: macsmc-gpio-irq-tests passes (4/4); pcie-sd-off-tests passes (4/4). |
|
@RyanTheTide the respin is a119be7 on
Checked on the host: None of this head has run on the J604 yet. That includes the new decision point (the reader now goes down right after the scan, not at ~11 s), the unbind and the deferral. Your HW row is next on this head: 10 boots with the slot empty, insert/read/write/remove/reinsert with the port off, one insert across a deep sleep, one unbind with the port down, and 0 AVC denials, failed units or new kernel errors. I'll post it here. This still follows #1962. |
1ea0914 to
a119be7
Compare
There was a problem hiding this comment.
Formal Pre-PR Checklist Re-Review (§1–§6) — REQUEST_CHANGES
Re-reviewed at verified live head a119be75d54e6bc073250e028208cd0b490ada9d (IronsideXXVI:j604-sd-reader-off → aurora-silicon/linux:integration/aurora). Live CI: all 9 check runs (host-tests, dt-checks, kunit ×2, rust-build, source, DWC3/ATC ×3) = success; merge state CLEAN.
Progress Since Prior Reviews
Documentation/devicetree/bindings/pci/apple,pcie.yaml:clkreq-gpiosandcard-detect-gpioseach have their ownmaxItems: 1.APPLE_PCIE_T8132_EXPreplaced withpcie_capability_read_word(rp, PCI_EXP_LNKSTA, &lnksta).- Commit 8 (
4fb7b294f224) removesAPPLE_PCIE_SD_BOOT_DELAY_MS(10 s fixed timer), moves probe deferral toapple_pcie_probe_port(), registersapple_pcie_sd_removebeforedevm_request_threaded_irq(), and callsapple_pcie_sd_stop()inapple_pcie_remove(). - All 9 commits now carry human author/committer (
Dylan Ironside) and humanSigned-off-by:only, with zero AI trailers in commits.
Blockers
- §2/§3 Safety —
apple_pcie_remove()/ unbind drops DART runtime PM hold while the port is still powered down (drivers/pci/controller/pcie-apple.c:3298-3310, 3369-3383, 6851-6874):- Commit 7 (
e2cd4a124f5e) established that lettingdart-apcie2runtime-suspend (apple_dart_save_state()) while the SD reader port is stopped and in reset causes a synchronous external abort / SError panic. - In
apple_pcie_remove(),apple_pcie_sd_stop()disables the card-detect IRQ and cancelssd_work, intentionally leaving the port powered down (port->sd_off == true, link stopped, endpoint in reset) whilepci_stop_root_bus()andpci_remove_root_bus()run. Immediately afterwards,devresrunsapple_pcie_sd_remove()→apple_pcie_sd_release_rp(), which callspm_runtime_put(dart)while the port is still stopped and in reset (re-exposing the exactapple_dart_save_state()SError hazard from Commit 7) and callspm_runtime_put(&rp->dev)on apci_devalready removed from the root bus. - Fix: Power the port back up (matching
PM_SUSPEND_PREPARE) and releasesd_rp_held/sd_dartinapple_pcie_sd_stop()beforepci_stop_root_bus(), or otherwise guarantee the root port and DART cannot runtime-suspend against a stopped port or after root-bus removal.
- Commit 7 (
- §2 Concurrency bug —
PM_SUSPEND_PREPAREvs card-detect IRQ /sd_workrace (drivers/pci/controller/pcie-apple.c:3209-3250):apple_pcie_sd_pm_notify()runs atPM_SUSPEND_PREPARE(before freezable workqueues are frozen) and callscancel_delayed_work_sync(&port->sd_work)whileport->sd_irqis still enabled.- Because
apple_pcie_sd_power_up()sleeps >100 ms and releasespcie->lockbeforepci_rescan_bus()andapple_pcie_sd_release_rp(), a card-detect IRQ arriving aftercancel_delayed_work_sync()can re-queue and runapple_pcie_sd_work()concurrently withapple_pcie_sd_power_up(), racing onport->sd_off,port->sd_rp_held,port->sd_dart, andpci_rescan_bus(), or powering the port back down right before system suspend. - Fix: Disable
port->sd_irq(or serializesd_workandapple_pcie_sd_pm_notify()with a per-port mutex and suspend state, re-enabling inPM_POST_SUSPEND/PM_POST_HIBERNATION) before cancellingsd_workand callingapple_pcie_sd_power_up().
- §2 Error-path state leak —
apple_pcie_sd_power_up()leavespwren_gpioon after failure (drivers/pci/controller/pcie-apple.c:3136-3173):- If
apple_pcie_port_reset_endpoint()or link training fails aftergpiod_set_value_cansleep(port->pwren_gpio, 1), the error path returns withport->sd_off = truewhile leavingpwren_gpioasserted (andPERST#deasserted if reset succeeded). Re-assertPERST#and droppwren_gpioon failure so hardware state matchesport->sd_off == true.
- If
- §5 Evidence — Live head
a119be75d54eand core card-insert/power-up path untested on hardware:- As acknowledged in the PR body, live head
a119be75d54ehas not been booted on J604 yet (including the post-scan decision point, unbind/remove with the port down, probe deferral, card-detect active-high polarity confirmation with a card inserted, insert/read/write/remove/reinsert from the powered-down state, and insert across deep sleep), and has no §5 regression tuple (0 AVC/SELinux denials,0 failed units,0 new kernel errors) on this head.
- As acknowledged in the PR body, live head
- Sequencing dependency —
#1962still OPEN and DRAFT (de49b8097bd3):- On
integration/aurora,&port02int8132-j604.dtsremains disabled until#1962lands; this series remains inert on Aurora's J604 tree until#1962is merged.
- On
Pre-PR Checklist Summary (§1–§6)
- §1 No model gating: PASS — gated on DT
card-detect-gpiosandinterrupt-controller. - §2 Production-ready, no hacks: FAIL —
PM_SUSPEND_PREPAREvs IRQ/work race, remove/unbind DART & root-port teardown order, and power-up failure rail leak. - §3 Safety: FAIL — remove/unbind path drops DART runtime PM ref while port 2 is still stopped/in reset.
- §4 Clean-room & attribution: PASS — all 9 commits carry human author/committer (
Dylan Ironside) and humanSigned-off-by:only, zero AI trailers in commits. - §5 Evidence: FAIL — live head
a119be75d54eunbooted, card-insert/power-up path never exercised on hardware, missing §5 regression tuple; blocked behind draft#1962. - §6 Naming: PASS.
|
@DjDeveloperr thanks, you were right on 1 to 3. The branch is now 4eb05ee, three commits on top of a119be7, no force-push.
Commits 10-12 sit after the J604 node because I'm only moving the branch forward during review. I can fold them into 4 and 8 before merge if you'd rather. Checks on this head: LLVM and GCC W=1 clean on |
There was a problem hiding this comment.
Formal §1–§6 pre-PR re-review at live head 4eb05ee09c48f287c7e14f6e502fba664b3c96bb (12 commits; base integration/aurora 377060f3688a, merges cleanly onto 70a00e583b03; not superseded; live CI: all 9 checks PASS, MERGEABLE/CLEAN).
Progress Verified Since Prior Review
- Commit 10 (
9adb0c2e5e9c):apple_pcie_sd_port_off()cleanly consolidates the power-down hardware sequence and preventsapple_pcie_sd_power_up()failure paths from leavingpwren_gpioon orPERST#deasserted whilesd_off == true. - Commit 11 (
a8adca8b1750):apple_pcie_sd_stop()now powers an off port back up and releasessd_rp_held/sd_dartbeforepci_stop_root_bus(), and intentionally keeps the DART runtime PM reference if power-up fails soapple_dart_save_state()cannot abort against a port in reset. - Commit 12 (
4eb05ee09c48):PM_SUSPEND_PREPARE/PM_HIBERNATION_PREPAREnow disablesport->sd_irq(tracked viasd_asleep) beforecancel_delayed_work_sync()and re-enables inPM_POST_SUSPEND/PM_POST_HIBERNATION, andapple_pcie_sd_stop()unlists the port before touchingsd_irq, closing thePM_SUSPEND_PREPAREvs card-detect IRQ/work race andstop()vs notifier race. - §4 Attribution: All 12 commits carry human author/committer (
Dylan Ironside <[email protected]>) and humanSigned-off-by:only, zero AI commit trailers; PR body carriesAssisted-by:.
Blockers Remaining
- §5 Hardware Evidence — live head
4eb05ee09c48and core card-insert/power-up path still untested on hardware:- As acknowledged in the PR body/comment, zero hardware tests have run on
4eb05ee09c48yet (post-scan decision point, unbind/remove with port down, probe deferral, deep sleep with empty slot), and the core card-insert / power-up path (active-high card-detect polarity confirmation with a card inserted, insert while powered down, file read/write, remove & reinsert, insert across deep sleep) has never been exercised on J604 hardware, with no §5 regression tuple (0SELinux denials orN/A,0failed units,0new kernel errors) on this head.
- As acknowledged in the PR body/comment, zero hardware tests have run on
- Sequencing dependency —
#1962is stillOPENandDRAFT(de49b8097bd3):- On
integration/aurora,&port02inarch/arm64/boot/dts/apple/t8132-j604.dtsremains disabled until#1962lands; this PCIe path stays inert on Aurora's tree until#1962merges.
- On
- §2/§3 Residual code & bisectability fixes for the next respin:
- Probe vs
PM_SUSPEND_PREPARElock gap (drivers/pci/controller/pcie-apple.capple_pcie_sd_start()):apple_pcie_sd_init()addsporttoapple_pcie_sd_portsbeforeapple_pcie_sd_start()runs, butapple_pcie_sd_start()writesport->sd_started = true, callsenable_irq(port->sd_irq), and queuessd_workwithout holdingapple_pcie_sd_lock. A concurrentPM_SUSPEND_PREPAREcan observesd_started == false(skippingdisable_irq()/sd_asleep) immediately beforeapple_pcie_sd_start()enables the IRQ and queuessd_work, or interleave betweensd_started = trueandenable_irq(). Holdapple_pcie_sd_lockaround thesd_started/enable_irq()/mod_delayed_work()update (or register the port onapple_pcie_sd_portsinapple_pcie_sd_start()). - Fail-safe DART hold on power-down (
apple_pcie_sd_hold_dart()/apple_pcie_sd_power_down()): Ifapple_pcie_sd_hold_dart()fails (e.g.,pm_runtime_resume_and_get(&pdev->dev) < 0orof_map_iommu_id()fails), it logs a warning and returnsvoid, andapple_pcie_sd_power_down()proceeds to remove the endpoint and stop/reset the port without holding the DART — re-exposing the Commit 7apple_dart_save_state()SError hazard. Return an error fromapple_pcie_sd_hold_dart()and abort power-down (releasingsd_rp_heldand leaving the port powered) when the DART cannot be held. - Bisectability: Please fold commits 10–12 into commits 4 and 8 (ahead of commit 9
t8132-j604.dts), as offered, so no intermediate commit turns on J604 power-down with the known rail-leak, remove-SError, and suspend-race bugs exposed.
- Probe vs
§1–§6 Checklist
- §1 No model gating: PASS — gated on DT
card-detect-gpiosandinterrupt-controller. - §2 Production-ready, no hacks: REQUEST_CHANGES — close the
apple_pcie_sd_start()vsPM_SUSPEND_PREPARElock gap and fold commits 10–12 ahead of the J604 DTS commit. - §3 Safety: REQUEST_CHANGES — abort
apple_pcie_sd_power_down()ifapple_pcie_sd_hold_dart()fails rather than stopping the port with an unheld DART. - §4 Clean-room & attribution: PASS.
- §5 Evidence: FAIL (blocking) — live head
4eb05ee09c48unbooted, card-insert/power-up path untested on hardware, missing §5 health tuple, and sequenced behind draft#1962. - §6 Naming: PASS.
On the MacBook Pro 14-inch (M4, J604) macOS keeps the SD reader's link off while no card is in: its root port and endpoint read all ones and the reader reports its link as off. The Apple device tree routes the slot's card detect to an SMC input (the reader's interrupt-parent is the SMC PMU, line 9), so the card is seen while the reader has no power. Linux keeps the reader powered and its link up with the slot empty. Do the same for a port whose node has card-detect-gpios: - An empty slot removes the reader from the bus, blocks the port's downstream access, holds the endpoint in reset and cuts its rail (pwren-gpios). - A card (the card-detect interrupt, both edges, 200 ms debounce) brings the rail back, resets the endpoint, trains the link as probe does with probe's endpoint-reset retries, and rescans, so the reader's driver probes it as a new device. A failed rail, reset or link puts the port back exactly as the power-down leaves it (apple_pcie_sd_port_off()), and the next card event tries again. - The APCIe block, the port's registers and its DART stay powered, as on macOS: only the endpoint loses power. - Before a system sleep the port is powered up, and the slot is checked again after it, so the sleep and resume paths only see a port as probe left it. - The first look at the slot waits 10 s after probe. Without the line or its interrupt the port is left as it is. There is no switch: a port without card-detect-gpios is not touched. The last commit of this series gives the J604's SD reader port the property; until then nothing changes on any machine. tools/asahi/pcie-sd-off-tests.py runs the decision (card, state) over every combination and kills three mutations: an empty slot left powered, the card detect inverted, an unreadable line taken as empty. Signed-off-by: Dylan Ironside <[email protected]>
With its slot empty the J604's SD reader is powered down and the root port's config space reads all ones, as macOS also reads it. The port is then childless, so the PCI core runtime-suspends it, and each D-state change finds no PMCSR to write: pcieport 0000:00:02.0: Unable to change power state from D0 to D3hot, device inaccessible pcieport 0000:00:02.0: Unable to change power state from D3cold to D0, device inaccessible (the second when a config read, lspci here, resumed it). Take a runtime PM reference on the root port before the reader goes down, while the port still answers, and drop it once the reader is back and rescanned, or when the port goes away. The port then stays as probe left it while the reader is off, and no D-state change is attempted on a port that cannot take one. Signed-off-by: Dylan Ironside <[email protected]>
With the slot empty the J604's SD card reader is powered down, its port reset with it, and that reset takes the root port's configuration too. When the reader is powered up again (a card, or every system sleep, which powers it up first), the root port reads its reset values: bus numbers 0, no memory window, memory decoding off. The rescan renumbers the bus but sets up no window behind a bridge that is already enabled, so every read of the reader's BAR came back all ones and sdhci logged "Reset 0x1 never completed" with an all-ones register dump, before and after each sleep. Save the root port's state at the power-down, while it still answers, and restore it after the link is back and before the rescan, as the radio's Neo path does before its own link. Signed-off-by: Dylan Ironside <[email protected]>
An empty slot takes the J604's SD reader off the bus, stops its port's link and holds the endpoint in reset, ten seconds after probe on a boot. Removing the endpoint drops the last runtime PM reference on the port's DART, and the DART's runtime suspend, which reads every stream's TCR and TTBRs to save them, runs later from the PM workqueue. When it lands after the port is stopped the read ends in a synchronous external abort and an SError, and with kernel.panic=0 the boot stops until the watchdog resets the Mac about a minute later. The panic records of two such resets on the J604 show it. One was an SError on CPU 2 after a data abort (EC 0x25, DFSC 0x10, a read) at apple_dart_save_state+0x44, and the FAR was in dart-apcie2 (0x492000000). The other was an SError on CPU 1 with the L2C latching 0x492001000, dart-apcie2's TCR block. The boot crumb of the first one stopped at 11 s, which is when the reader goes down. Both reset loops happened on two kernels with this code. Take a runtime PM reference on the port's DART, found through the host's iommu-map, before the endpoint is removed. Drop it after the reader is back and rescanned, when its own streams hold the DART again, or when the port goes away. The DART then saves nothing while its port is down. Its power domain stays on either way, with the radio's DART in it. If the DART cannot be held (no root port or secondary bus, no DART device behind the iommu-map entry, or its runtime resume fails), the power-down stops before it removes the endpoint: the root port's hold is released, the reader stays powered and the next card event tries again. A host without an iommu-map has no DART to hold. Signed-off-by: Dylan Ironside <[email protected]>
The first look at an SD reader port's slot waited a fixed 10 s after probe, and the card-detect interrupt was live from port setup. A fixed wait over a probe race is not a decision point, and nothing stopped the work from running against a bus that remove() had already taken down. - The card-detect interrupt is requested disabled. Probe enables it and reads the slot once the bus scan has enumerated the reader, so the first decision follows the scan instead of a timer. - The devres action that cancels the port's work is registered before the interrupt, so devres frees the interrupt first and nothing can queue the work after it is cancelled. - remove() disables the card-detect interrupt, takes the port off the sleep notifier's list and cancels its work before it takes the rescan lock and removes the root bus. - The sleep notifier is registered and unregistered outside the lock the notifier itself takes. - A card-detect line whose provider (or the provider's interrupts) is not there yet defers the host probe with the other port dependencies, before any port is touched, so whether the port can power down no longer depends on probe order. - remove() powers a port that is down for an empty slot back up, as the sleep notifier does, and releases the root port and DART holds itself, while the port is up and before the root bus goes. If that power-up fails the port stays in reset and the DART keeps its runtime PM reference for good, so it never saves its state against the port. - The sleep notifier disables the card-detect interrupt before it cancels the port's work and powers the port up, and enables it again after the sleep, before it checks the slot. With the interrupt off and the work cancelled nothing else can start a power change while the notifier runs. sd_asleep records which ports it turned off. remove() takes the port off the notifier's list before it touches the interrupt. - Probe turns the interrupt on under the notifier's lock. A port that probe starts between a PREPARE and its POST keeps the interrupt off, and the POST turns it on and reads the slot. The decision is not moved ahead of training: the power-up path puts back the root port state saved at the power-down, and a port that never trained has none to put back. Signed-off-by: Dylan Ironside <[email protected]>
The J604's SD reader reports its card detect through the SMC's gP09 (Apple device tree pcie-sdreader: interrupt-parent smc-pmu, interrupts <9>, card-detect-polarity 1). Describe it on the reader's root port and let the SMC GPIO node offer interrupts. With it the PCIe driver powers the reader's port down while the slot is empty, as macOS does. The level read with a card in and out is to be confirmed on the machine; active high follows the Apple device tree's polarity of 1. Signed-off-by: Dylan Ironside <[email protected]>
4eb05ee to
ace5394
Compare
|
Thanks. Respun as ace5394, 9 commits.
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: HOLD at ace53941c515
Blockers:
- PR body (§4 — AI attribution): Remove the AI attribution line at the bottom of the PR description; under the updated §4 policy, commits, PR titles, PR bodies, comments, and reviews must carry zero AI attribution.
- PR body & §5 evidence (J604 + second-Mac regression at
ace53941c515): No hardware rows have run onace53941c515yet, and the core card-insert/power-up path has not been exercised on hardware. Post exact-head rows atace53941c515covering:- J604 (default cmdline): 10 empty-slot boots (reader powered down, no DART fault), card-detect active-high polarity confirmation with card inserted, insert while powered down, file read/write, remove and reinsert, insert across deep sleep, unbind/remove with port down, plus the §5 health tuple (0 SELinux/AVC denials or N/A if SELinux is absent, 0 failed units, 0 new kernel errors).
- One other PCIe/SMC Mac (regression row for shared
drivers/pci/controller/pcie-apple.canddrivers/gpio/gpio-macsmc.c): boots atace53941c515with 0 SELinux denials, 0 failed units, 0 new kernel errors. - Add
Tested:(Macs at head SHA + result) andRisk:(one-way door due to new DT bindings + affected Macs) lines to the PR body.
- Sequencing dependency (
#1962):aurora-silicon/linux#1962(de49b8097bd3) is still open and draft; onmain,&port02inarch/arm64/boot/dts/apple/t8132-j604.dtsstays disabled until#1962lands, so this remains held behind#1962.
Checked: §1–§6 pre-PR checklist, exact interdiff 4eb05ee09c48 → ace53941c515, full 9-commit diff, PR metadata/body, and live CI (9/9 green). All code, safety, and bisectability blockers from 4eb05ee09c48 are resolved.
Evidence
- Interdiff
4eb05ee09c48→ace53941c515: 9 of 10 touched files are byte-identical; onlydrivers/pci/controller/pcie-apple.cchanged:- Fixed:
apple_pcie_sd_start()now locksapple_pcie_sd_lockand checksapple_pcie_sd_sleeping(set acrossPM_SUSPEND_PREPARE/PM_HIBERNATION_PREPAREtoPM_POST_SUSPEND/PM_POST_HIBERNATION), closing the probe vs suspend-prepare lock gap. - Fixed:
apple_pcie_sd_hold_dart()now returns aninterror (returning0only when already held, held viapm_runtime_resume_and_get(), or whenof_map_iommu_id()returns0with!args.np), andapple_pcie_sd_power_down()aborts before removing the endpoint and releasessd_rp_heldon failure, closing the unheld-DART SError hazard. - Fixed: old commits 10–12 are folded into commits 4 (
2df03e12dc64) and 8 (679fa9dc6dff), with the two new fixes in commits 7 (54305a16b1a6) and 8 (679fa9dc6dff);arch/arm64/boot/dts/apple/t8132-j604.dts(ace53941c515) is last so every intermediate commit is bisectable.
- Fixed:
- Checklist summary at
ace53941c515:- §1 No model gating: PASS — gated on DT
interrupt-controller(drivers/gpio/gpio-macsmc.c:634) andcard-detect-gpios(drivers/pci/controller/pcie-apple.c:3343), with per-line IRQ capability probed viaCMD_IRQ_MODE. - §2 Production-ready, no hacks: PASS — no cmdline/module parameters, no boot-delay timer, probe deferral handled in
apple_pcie_probe_port(). - §3 Safety: PASS (code) — fail-safe DART hold,
apple_pcie_sd_stop()powers up beforepci_stop_root_bus()and retains DART PM ref on failure,apple_pcie_sd_power_up()error path restoresapple_pcie_sd_port_off(). - §4 Clean-room & attribution: Commits 1–9 PASS (all human author/committer
Dylan Ironsideand humanSigned-off-by:only, zero AI commit trailers); PR body FAILS due to the trailing AI attribution line. - §5 Evidence: BLOCKED — no hardware rows at
ace53941c515yet, card-insert/power-up path untested on J604, missing second-Mac regression row, missingTested:/Risk:in PR body, and held behind draft#1962. - §6 Naming: PASS.
- §1 No model gating: PASS — gated on DT
- Live CI on
ace53941c515881c8f7fa1276581838a561355f2: 9/9 green (dt-checks,host-tests,kunit×2,rust-build,source,DWC3/ATC×3);mergeable: MERGEABLE,mergeStateStatus: BLOCKED. - Non-blocking nit: In
drivers/pci/controller/pcie-apple.c:3302-3316(apple_pcie_sd_unlist()), if the last port unlists betweenPM_SUSPEND_PREPAREandPM_POST_SUSPEND,unregister_pm_notifier()stopsPM_POST_SUSPENDfrom clearingapple_pcie_sd_sleeping; resettingapple_pcie_sd_sleeping = falsewhenlastis true underapple_pcie_sd_lockavoids stale state on a later re-probe.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Thanks. The footer is gone; the description is now the What / Tested / Risk / Not yet form with nothing else at the bottom. The exact-head rows on ace5394 aren't in yet. The empty-slot boots, the unbind with the port down and the health tuple run without me; the card insert, remove/reinsert and insert-across-sleep rows need a card in hand, so they go in one sitting. I'll post them here together, plus the second-Mac row if I can get one, or say plainly that I couldn't. |
There was a problem hiding this comment.
Requesting changes at ace53941c515 after a full code and DT architecture audit. In addition to the pending J604 card-insert / power-up hardware verification and #1962 sequencing already noted on this PR, there are four technical defects / non-gating issues in the driver and DT changes:
-
Stuck
apple_pcie_sd_sleepinglatch when the last SD port unlists during a sleep window (drivers/pci/controller/pcie-apple.c):apple_pcie_sd_pm_notify()sets the module-globalapple_pcie_sd_sleeping = trueonPM_SUSPEND_PREPARE/PM_HIBERNATION_PREPAREand only clears it inPM_POST_SUSPEND/PM_POST_HIBERNATION.- If the sole SD-managed port is removed via
apple_pcie_sd_unlist()during that window (for example, a probe failure afterapple_pcie_sd_init()unwinding throughapple_pcie_sd_remove()),apple_pcie_sd_unlist()seeslast == trueand callsunregister_pm_notifier(&apple_pcie_sd_pm_nb). - Because the notifier is now unregistered,
PM_POST_SUSPENDnever clearsapple_pcie_sd_sleeping; a subsequent re-probe seesapple_pcie_sd_sleeping == trueinapple_pcie_sd_start(), setsport->sd_asleep = true, and leaves card-detect permanently disabled until another suspend/resume cycle firesPM_POST_SUSPEND. - Keeping the PM notifier registered for the module lifetime (or clearing/re-syncing sleep state safely rather than unregistering mid-sleep) avoids stranding
apple_pcie_sd_sleeping.
-
Silent root-port runtime-PM / config-save failure in
apple_pcie_sd_power_down()(drivers/pci/controller/pcie-apple.c):- While
apple_pcie_sd_hold_dart()failure cleanly aborts power-down before removing the endpoint, a failure ofpm_runtime_resume_and_get(&rp->dev)(orpci_save_state()) is silently ignored:port->sd_rp_heldremainsNULL, yetapple_pcie_sd_power_down()proceeds to remove the endpoint and cut power anyway. - As commits 5 and 6 note, powering down without holding the root port active and saving its config state leaves the PCI core to runtime-suspend an all-ones root port and causes
apple_pcie_sd_power_up()to skippci_restore_state(), leaving the bridge at reset defaults (bus 0, no memory window, BARs reading0xffffffff). - Treat root-port RPM acquisition and
pci_save_state()failure the same way asapple_pcie_sd_hold_dart()failure and abort power-down cleanly before touching the endpoint or rail.
- While
-
Ignored
apple_pcie_sd_power_up()failure inPM_SUSPEND_PREPARE(drivers/pci/controller/pcie-apple.c):apple_pcie_sd_pm_notify()callsapple_pcie_sd_power_up(port->pcie, port)without checking its return value and always returnsNOTIFY_OK. If power-up fails before sleep, system suspend proceeds intoapple_pcie_suspend_noirq()withport->sd_off == trueand bothsd_rp_heldandsd_dartstill held active. Returnnotifier_from_errno(ret)(or explicitly handle failure) rather than silently continuing suspend in a half-recovered state.
-
SMC GPIO event matching & SoC-wide vs board-gated
interrupt-controller(drivers/gpio/gpio-macsmc.c,arch/arm64/boot/dts/apple/t8132-j604.dts):macsmc_gpio_of_tablebinds both"apple,smc-gpio"(gP) and"apple,smc-low-gpio"(gp) tomacsmc_gpio_probe(), andmacsmc_gpio_event()matches(event >> 16) == SMC_EV_GPIO(0x7202) without distinguishingbase_key(or restrictingmacsmc_gpio_init_irq()togP/"apple,smc-gpio"). If agpnode is ever markedinterrupt-controller, both instances will consume0x7202and sendCMD_IRQ_ACKtogpXXkeys.- In DT,
&smc_gpiois defined in the sharedt8132.dtsi, andmacsmc_gpio_init_irq()already dynamically probes which lines the SMC firmware supports viaCMD_IRQ_MODE. Puttinginterrupt-controller/#interrupt-cells = <2>only int8132-j604.dtsneedlessly gates SMC GPIO interrupts to J604 instead of enabling the controller capability int8132.dtsi(while keeping per-port opt-in on board-specificcard-detect-gpios).
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at ace53941c515: the code is ready; it needs only a row at this head.
Blockers: none in the code. Missing row: one J604 boot at this head with the empty SD reader powered down (as macOS does) and a card inserted later still working. I removed the attribution line from the body. Thanks.
Because gpio-macsmc.c and pcie-apple.c run on every Mac, it also needs one boot at this head on another generation with PCIe devices and SMC GPIOs unchanged before it merges.
Checked: no Apple material, no board gates. CI green.
Superseded by the review at ace5394
satchlj
left a comment
There was a problem hiding this comment.
Verdict: MERGE at ace53941c515881c8f7fa1276581838a561355f2
Blockers: none
Checked:
- Read again at this head; nothing shows a path that breaks a working Mac on the default command line. Host tests and mutation checks pass at every commit, and CI is green.
- My four earlier points are error and edge paths nobody has hit, so they move to follow-ups: keep the PM notifier registered so
apple_pcie_sd_sleepingcannot stick; abort power-down when the root port RPM get orpci_save_state()fails; act on a failed power-up inPM_SUSPEND_PREPARE; separategpandgPevents ingpio-macsmc. - Still for the merge gate: the J604 row at this head (empty-slot boot, card inserted later), and one boot on another generation with PCIe devices and SMC GPIOs unchanged.
Evidence
No commits since my last review.
What: Power the J604 (M4, T8132) SD card reader down while its slot is empty, as macOS does, and bring it back when a card arrives. The card detect comes from an SMC input (line 9) through new macsmc GPIO interrupts. Only the last commit (the t8132-j604 DT node) turns this on. Commits 1-8 change nothing on any machine without
card-detect-gpioson a port and an SMC node markedinterrupt-controller. On Aurora's J604 tree this follows #1962.Tested: No hardware result for this head (ace5394) yet. Checked on base 5b596e6: each of the 9 commits builds
pcie-apple.oandgpio-macsmc.owith clang 18.1.3 and W=1 (0 warnings, 0 errors),t8132-j604.dtbbuilds withcard-detect-gpios, the host testsmacsmc-gpio-irq-tests(8) andpcie-sd-off-tests(6) pass at every commit, and each mutation is caught. The branch also merges cleanly ontointegration/aurora70a00e5.Risk: two-way · J604 (M4 MacBook Pro 14"). No J713 or other node has
card-detect-gpiosor an SMCinterrupt-controller.Not yet: The J604 run on the 4eb05ee tree (slot-empty boot, unbind/bind with the port down, 3 deep sleeps, kernel-error count against base) is to be posted, then repeated on this head. Not run at all: a card inserted while the port is off, the card-detect level with a card in, and a card across a system sleep. Ryan's J604 row (10 boots, insert/read/write/remove/reinsert, insert across deep sleep, 0 AVC denials, failed units or new kernel errors) comes after that.
Full description
On the MacBook Pro 14" M4 (J604, T8132), macOS keeps the SD card reader off while its slot is empty. Its root port and endpoint read all ones. macOS still sees a card through the SMC's card detect, which the Apple device tree routes to an SMC input (line 9). Linux keeps the reader powered with the link up. This series makes Linux do the same, in this order:
gpio: macsmc: the SMC's input interrupts (event 0x7202, ack command 5). They are enabled only for a node markedinterrupt-controller, so no other Mac changes.dt-bindings: gpio: apple,smc-gpio: allowinterrupt-controllerand#interrupt-cellson the SMC GPIO node.dt-bindings: pci: apple,pcie: a port'scard-detect-gpios.PCI: apple: power a card reader port down while its slot is empty. A card brings the rail back, resets the endpoint, trains the link as probe does and rescans. A failed rail, reset or link puts the port back exactly as the power-down leaves it (apple_pcie_sd_port_off()), and the next card event tries again. Only a port withcard-detect-gpiosis touched. There is no module parameter.remove()takes the port off the notifier's list, disables the interrupt and cancels the work, then powers an off port back up and releases the root port and DART holds itself, before it removes the root bus. If that power-up fails, the DART keeps its runtime PM reference for good, so it never saves its state against a port in reset.arm64: dts: apple: t8132-j604: the reader's card detect on SMC line 9 and its interrupt. This commit turns the power-down on for the J604. Before it, commits 4-8 change nothing on any machine.Commit 7 comes before the J604 node on purpose. Without it, our own kernels with this code on sometimes froze at boot. The panic records of two such boots point at the DART's TCR at 0x492001000 (
dart-apcie2), read fromapple_dart_save_stateon the PM workqueue about 11 s into boot, the moment the reader powered down. On our 1.926, which carries the DART hold, ten reboots in a row with the slot empty gave no freeze of this kind; before the hold there were 2 such freezes in about 7 boots (2026-11-15). Ten boots are evidence, not proof. Those boots used the 10 s timer that commit 8 removes, so the reader now goes down earlier in boot, and that timing has not been booted yet.Changed in this revision (review of 2026-11-23 22:06):
PM_SUSPEND_PREPARE:apple_pcie_sd_start()now runs underapple_pcie_sd_lock. The notifier sets a flag under the same lock from PREPARE to POST, and a port started inside that window keeps its interrupt off (sd_asleep), so POST turns it on and reads the slot.apple_pcie_sd_hold_dart()returns an error, andapple_pcie_sd_power_down()stops before it removes the endpoint when the hold fails. A host without aniommu-maphas no DART, and that is not an error.git diffbetween the folded head and that linear branch is empty.Not tested on hardware yet:
The J604 row Ryan listed will go here: 10 boots with the slot empty, insert/read/write/remove/reinsert with the port off, one insert across a deep sleep, one unbind with the port down, and 0 AVC denials, failed units or new kernel errors.
For the J713 tree: nothing here runs without
card-detect-gpioson a port, and the SMC irqchip only exists for a node markedinterrupt-controller. No J713 node has either.Order: on Aurora's J604 tree, port 2 stays disabled under the managed contract until #1962 admits it, so this follows #1962.
Checked on base 5b596e6 (this branch ace5394), 2026-11-23. The branch also merges cleanly onto the current
integration/auroratip 70a00e5.pcie-apple.oandgpio-macsmc.owith LLVM (clang 18.1.3) and W=1: 0 warnings, 0 errors at each of the 9 commits.t8132-j604.dtbbuilds and carriescard-detect-gpios.macsmc-gpio-irq-tests8 cases andpcie-sd-off-tests6 cases pass, and eachpcie-sd-off-testsmutation is caught. They cover the slot decision, not the remove or sleep paths.