Repository navigation
usb: typec: tipd: keep a CD321x/SN201202x port from going deaf after s2idle (lost event IRQ) - #338
Merged
Merged
Conversation
The CD321x and SN201202x controllers latch their events in INT_EVENT1 until the host writes them to INT_CLEAR1, and raise their interrupt only when an event is latched while none were pending. When cd321x_interrupt() fails to read the latched events it returns without acknowledging them, so the controller never interrupts again, and the port ignores every later plug, power and Alternate Mode change until the driver is rebound. A failed write to INT_CLEAR1 does the same, and a failed status read after the acknowledgment drops the change behind the event. On the J700 the rear-port SN201202x hits this after s2idle: its event handler runs while the controller is still in SPMI sleep, the register select times out, "cd321x_interrupt: failed to read events" is logged, and the port stays dead for the rest of the boot. The resume revalidation reads a fresh snapshot but leaves the latched events alone, so it does not recover the port either. Acknowledge latched events at the start of every snapshot read, which covers them, and have an interrupt that could not read, acknowledge or apply its events schedule such a read with a full retry budget. A port whose earlier recovery gave up is included, since no further interrupt can arrive to reopen it. Failures during suspend or probe need nothing extra, because both end with a snapshot read. A failed read says nothing about the cable, so it does not force a reconnect. Keep the acknowledgment apart from the bounded budget for reading and applying the cable state. While the events stay latched, no interrupt can restart a recovery that gave up, so a snapshot read that fails to acknowledge them is not charged to that budget and never gives up: it is retried after a delay that doubles from 500 ms to at most 30 s. Sleep cancels the retry and the resume read takes it over, and removal ends it. Only the first failure of a series is logged. Add KUnit tests that model the controller's event latch behind a regmap and drive the interrupt handler and the snapshot worker. They check that the next event still raises an interrupt after a failed event read, clear or status read, after a failed read on a port that had given up, and after events latched across a sleep cycle; also when the event reads or clears keep failing long after the cable-state budget has run out, including across a sleep cycle, before the bus recovers. They also check that removal stops the retries. Without this change, all of them fail except the one where the interrupt succeeds. State machine tests check the retry delay and that the acknowledgment leaves the cable-state budget alone. Fixes: 45188f2 ("usb: typec: tipd: Add support for Apple CD321X") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
When cd321x_interrupt() fails to read the identity of a PD partner after a power status change, it logs the error, clears the identity and goes on to queue the cable update. The event has been acknowledged by then, and nothing reads the identity again. The update then registers a new partner with an all-zero identity, or, for a partner that is already registered, takes the changed identity for a different partner and tears down a working connection to register it again. Handle the failure like the other failed reads in the interrupt: leave the queued state alone and schedule a fresh snapshot read, which reads the identity together with the rest of the cable state, retrying within the usual budget. Add a KUnit test whose identity read fails once: the identity in use must be kept until the fresh read has succeeded, and then be replaced. Without this change it fails. Fixes: 36c791c ("usb: typec: tipd: Update partner identity when power status was updated") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
…er sleeps sn201202x_suspend() puts the controller into SPMI sleep, and sn201202x_resume() wakes it again, but its event interrupt stays enabled for the whole time. An event latched around suspend is handled while the controller sleeps: during suspend until the interrupt is suspended, and during resume as soon as the interrupt is replayed after the noirq phase, before the wakeup command has been sent. The register select then times out and the event read fails. On the J700 this shows up after s2idle as "sn201202x 1-0c: cd321x_interrupt: failed to read events", logged during device resume, with no further rear-port event for the rest of the boot. Disable the event interrupt before the controller is put to sleep, and enable it again once the controller is awake, or when suspend fails. An interrupt arriving meanwhile is replayed when it is enabled, and the resume revalidation acknowledges anything latched during sleep. A resume whose wakeup fails still enables the interrupt, so that a later event can be handled once the controller answers. Polled controllers have no event interrupt and are unaffected. Fixes: 419cafb ("usb: typec: tipd: Add sn201202x support") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
sn201202x_suspend() fails the suspend when the controller does not confirm the SLEEP command within 100 ms, and rolls back with tipd_resume(). The controller accepted the command, though, so it may well be asleep with only the confirmation missing. The PM core does not resume a device whose suspend failed, so nothing wakes the controller: the rollback reads its registers, its event interrupt is enabled again, and every event read then fails until the next system sleep. Send WAKEUP before rolling back once SLEEP was accepted. A failed wakeup is logged, and the suspend still fails with its own error. A SLEEP command that was rejected leaves the controller awake and needs no wakeup, as before. Failing the suspend, where the Asahi driver only logs the missing confirmation, is kept, so that the system does not sleep with the controller in an unknown state. Make the system sleep callbacks visible to KUnit and test them on a simulated SPMI bus: a sleep cycle keeps the event interrupt off while the controller sleeps, a failed wakeup at resume still enables it, a rejected SLEEP is not followed by a wakeup, and a SLEEP that is never confirmed is followed by a wakeup before the event interrupt is enabled again, also when that wakeup fails. Without this change the last two fail. Fixes: 38c14f6 ("drm: apple: support ProMotion variable refresh rate") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
cd321x_test_recover() asserted that the recovery read was still pending before flushing it. The driver queues that read with no delay, so on an SMP test machine a worker can run it before the assertion, and the test fails although the driver behaved correctly. With four CPUs, cd321x_resume_acknowledges_events_test failed 1 time in 5. Check the read's effect instead. After the flush the port must accept updates again, which it only does once the recovery read has run. Removing the resume path's mod_delayed_work() still makes the test fail. Fixes: 7e97f2f ("usb: typec: tipd: cd321x: Never leave interrupt events unacknowledged") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
This was referenced Oct 17, 2026
Merged
RyanTheTide
added a commit
that referenced
this pull request
Oct 17, 2026
Bring the 7.2.10 assembly to the tree of the canonical top-up #5 assembly 1c824ed, stacked on top-up #4 5043778 so that it is a fast-forward of the published branch. The second parent is that canonical assembly; the tree is identical to it. Ported from aurora-wip, each with cherry-pick -x and its original author: - #338 tipd lost IRQ (5): never leave CD321x interrupt events unacknowledged, recover from a failed partner identity read, keep SN201202x events unhandled while it sleeps and wake it when suspend fails, and the KUnit race fix of the IRQ test (170-usb). - #339 Touch ID verify retry (2): say why the sensor status after registration was unusable, and retry a failed sensor bring-up before a verify (100-sep). - #340 USB and Bluetooth wake v4.1 (30): AIC wake (010-soc); xHCI, DWC3 and hub suspend-to-idle wake with their KUnit tests (170-usb); MT7932 Bluetooth wake and MSI wake for Apple PCIe (080-radio); the apple-dcp DWC3 wake model (200-dcp); the tools/aurora-wake regression tools (900-config-tooling). - #341 apple-dcp selftests for the tipd lost-IRQ helpers (200-dcp). - batch1 backlog: rust-clippy (4; 070-audio, 210-gpu), boot-warnings (3; 200-dcp), and the 4 harden-all commits not yet carried (010-soc qspi resume, 070-audio AOP wrapped-entry test, 200-dcp start completion). kunit-parsers, spi-apple-cs and the other 34 harden-all commits were already in the topics, including the AOP ring fix that top-up #4 brought; it is not duplicated. Not ported: 3132675, superseded on 7.2.10 by b69728b ("selftests: apple-dcp: Follow the 7.2.10 driver boundaries"). Adaptations, each with a [ryan: ...] note in its commit: - the new tipd KUnit tests take the CD321x and SN201202x data from the exported tipd_hw_variants[] table of 7.2.10; - the #341 lifecycle.py import also keeps ATC_POST_TUNABLE; - drm/asahi statistics style without the driver.rs part, which 7.2.10 already has; - the Rust doc example refresh only for KVec and Drain: iosys_map.rs, the old IoMem example and declare_flags_type!() are gone in 7.2.10; - "Do not arm the core interrupt for wakeup" split between 170-usb and 200-dcp. New: 11e0ce6 ("usb: typec: tipd: cd321x: Don't race the resume read in the sleep retry test"). Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
This was referenced Oct 17, 2026
RyanTheTide
added a commit
that referenced
this pull request
Oct 17, 2026
cd321x_update_work() decides inline whether a cable update first reports the external display as disconnected, and whether it reports the display as connected once the mux is set. The conditions mix Type-C session state with the DisplayPort HPD and pin assignment bits of DATA_STATUS, and so far they could only be exercised with real cables. Move them into cd321x-dp.h as pure functions of the update's DATA_STATUS, the bits that changed since the previous update and whether a display route was up, and add KUnit tests that pin down the current behaviour. No functional change. [ryan: rebased onto aurora-wip 0daed2d + ATC PIPE park v3. Kconfig and Makefile: the tests' help text and objects follow those of the interrupt (#338) and held-mux (PIPE park v3) tests. core.c: cd321x_dp_notify() follows v3's cd321x_retry_held_mux() and cd321x_update_done(), and the connected event is sent before v3's cd321x_update_done(). No other change.] Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]> (cherry picked from commit 44e5333 ("usb: typec: tipd: Factor out the CD321x DisplayPort hotplug decisions")) Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
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.
After an s2idle cycle, a USB-C controller on the MacBook Neo can go "deaf": it stops reporting plug, power and partner changes until the driver is rebound. It happened to the rear port on 2026-10-16.
Cause
INT_EVENT1empty → non-empty edge, and it holds events latched until the host writesINT_CLEAR1.WAKEUP. So the handler's event read times out.INT_EVENT1non-empty. No new edge could ever arrive, so the port never interrupted again.Fix (4 commits + 1 test fix)
SLEEPand enabled afterWAKEUP, so a pending edge is handled once the controller can answer. SPMI only (J700/M3+).Testing
cd321x-pm,cd321x-tbt,cd321x-irqandsn201202x-pmpass 48/48 with the SPMI config, and every commit bisects clean;3f12d3d7with commit 5: both configs pass (43/43 and 48/48), with 10 repeated runs and the mutant check.drivers/usb/typec/tipd/is clean with the published config.failed to read/clear events,failed to acknowledge,cable revalidation failed,failed to read partner identity,failed to suspend,bad_chained_irq), and 0 WARN/BUG;🤖 Generated with Claude Code