Skip to content

usb: typec: tipd: sn201202x: idle sleep where the DT says the event IRQ stays live - #1889

Open
AxxzyWasTaken wants to merge 5 commits into
aurora-silicon:integration/aurorafrom
AxxzyWasTaken:t6041-usbc-idle
Open

AxxzyWasTaken wants to merge 5 commits into
aurora-silicon:integration/aurorafrom
AxxzyWasTaken:t6041-usbc-idle

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

#833 lets the SN201202x controllers sleep while idle, but only where the controller has no select notification, which is T8132. The M4 Max (T6041) has four SN201202x controllers (1-08, 1-0a, 1-0c, 2-0c on the J616c), each with a select interrupt, so none of them ever sleeps.

Their event interrupt stays live while they sleep, as on T8132. That is the one thing idle sleep needs: a register access wakes the controller through runtime PM first. This PR gives them the same idle sleep (1 s autosuspend), selected by the device tree:

  • dt-bindings: apple,event-irq-in-sleep (boolean) on the SN201202x node: the controller's event interrupt stays live while it sleeps.
  • dts: set on every SN201202x of the T6041 boards: the four on the J614c and J616c (shared file) and the four on the J575c.
  • tipd: sn->idle_sleep follows the property. T8132's select-polled controllers keep idle sleep as before. No machine compatible is checked.

T6041's system sleep stays as in integration/aurora: the event IRQ keeps enable_irq_wake(), and suspend wakes a controller that is asleep from idle through runtime PM first (DjDeveloperr's review, 479d42a). Other boards keep their controllers awake until their DT has the property.

Tested

On a J616c (14-core M4 Max), on the bring-up daily (7.3.0, integration/aurora + local patches). The test build had the same condition behind a module parameter (idle_sleep=1) instead of the machine check; the logic in between is identical.

  • All four controllers runtime-suspend at idle (power/runtime_status = suspended).
  • Power, awake (power/control = on) against asleep (auto), three rounds of 10 s each. SoC (Heatpipe Power): 1.85 / 1.86 / 1.87 W awake against 1.74 / 1.75 / 1.76 W asleep. System total: 4.89 / 4.92 / 5.05 W against 4.85 / 4.86 / 4.85 W.
  • A USB device plugged into a USB-C port while all four slept was detected (port3 partner). The controllers went back to sleep with it attached.

On this branch (the first commit alone on integration/aurora 5b36eff): spmi.o builds with LLVM=1 W=1 with no warnings, and checkpatch is clean.

The DT commits (19 Nov): spmi.o and sn201202x-pm-test.o build with LLVM=1 W=1 with no warnings. The J614c, J616c and J575c DTBs build, and CHECK_DTBS gives no new warnings against the previous head. dt_binding_check passes for apple,sn201202x.yaml. Each built DTB has apple,event-irq-in-sleep on all four SN201202x nodes, and on no others. tools/asahi/run-host-tests.py passes, 319/319.

Not tested

  • This exact commit booted.
  • A charger plug while the controllers sleep (charging runs through the SMC either way).
  • DisplayPort or USB4 attach while asleep. Per usb: typec: tipd: sn201202x: Sleep while idle #833 those links keep the controller awake once up, but the attach itself was not tried.
  • The J614c or J575c, which are also T6041.
  • The DT version booted. The idle-sleep code it selects is the one measured above.
  • Any board other than the J616c. The M4 Pro (T6040) and later chips with the same controllers stay awake until their device trees have the property.

@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.

Thanks. The idle-sleep result and the power numbers on the J616c are good. There's one problem before this can merge, in system sleep rather than idle sleep.

Setting tps->sleep_event doesn't only turn on idle sleep. It also moves T6041 to the system-sleep event filter. The event IRQ becomes IRQF_NO_SUSPEND (no enable_irq_wake()), and in s2idle sn201202x_sleep_event() reads the controller itself.

That read doesn't poll on T6041:

  • regmap_sn201202x_select_reg() polls only for polled || select_polled; sn->atomic only picks which poll.
  • On T6041 it waits up to 100 ms for the select interrupt. That's an ordinary device IRQ, disabled for the whole system sleep.
  • In s2idle the tick is frozen while the CPUs sit in s2idle, so that timeout may not fire until something else wakes the machine.

As far as I can read it, a USB plug during s2idle could then leave the IRQ thread blocked, holding tps->lock with the event line masked, instead of waking the system. Today T6041 wakes on any port event through enable_irq_wake(). This is the case the comment you edited guards against ("Register access then has to poll, which a select notification would not"), and system sleep isn't in the testing.

Either of these is fine:

  1. Poll the select in the sleep-event path too, e.g. if (sn->polled || sn->select_polled || sn->atomic) in regmap_sn201202x_select_reg(). Then run s2idle on the J616c: a USB device plugged in during sleep wakes it, a charger plug follows the filter, and the resume is clean.
  2. Enable only idle sleep on T6041: decouple sn201202x_idle_sleep_start()/_stop() from tps->sleep_event (e.g. a separate idle-sleep flag set for T8132 and T6041), and leave T6041's system-sleep path as it is. That matches what was tested.

host-tests is green; requesting changes for the s2idle path.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Thanks, you're right: setting tps->sleep_event also moved T6041 onto the system-sleep event filter, and T6041's select wait doesn't poll there.

I went with option 2 in 479d42a. A new sn->idle_sleep decides idle sleep on its own. It's set for T8132 and T6041, and sn201202x_idle_sleep_start()/_stop() follow it. tps->sleep_event, together with the system-sleep filter, stays T8132's alone. On T6041, system sleep is the same as in integration/aurora: the event IRQ keeps enable_irq_wake(), and suspend wakes a controller that's asleep from idle through runtime PM first. That matches what was tested. sn201202x-pm-test.c covers the new flag.

Checked on the J616c with this version: all four SN201202x (1-08, 1-0a, 1-0c, 2-0c) are runtime-suspended while idle. Not run: s2idle, since this change leaves T6041's system-sleep path as it is in the base.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr could you take another look when you have a moment? Your point is addressed in 479d42a (option 2, details in my comment above).

Idle sleep (aurora-silicon#833) is given only to controllers without a select
notification, which are the T8132 ones. The M4 Max (T6041) has four
SN201202x controllers with a select interrupt, and they stay awake for
as long as the system does.

Their event interrupt stays live while they sleep, as on T8132, and
register access in that state polls the same way. So give T6041's
controllers the same sleep event filter, and with it idle sleep.

On a J616c, all four controllers runtime-suspend at idle. Awake against
asleep, three rounds each: the SoC rail reads 1.85-1.87 W against
1.74-1.76 W, and the system total about 0.05-0.2 W lower. A USB device
plugged in while they slept was detected, and they went back to sleep
with it attached.

Assisted-by: LLM
Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
…leep filter

Giving T6041 tps->sleep_event also moved it to the system-sleep event
filter. That filter reads the controller from an IRQF_NO_SUSPEND event
interrupt, and on T6041 register access waits for the select interrupt,
which is disabled for the whole system sleep. A plug in suspend-to-idle
could then block the IRQ thread instead of waking the system.

Decouple the two. A new sn->idle_sleep lets a controller sleep while idle
where its event interrupt stays live (T8132 and T6041), and sleep_event,
with the system-sleep filter, stays T8132's alone. T6041 keeps its wake
IRQ in system sleep, as before; its suspend already wakes a controller
asleep from idle through runtime PM first.

Assisted-by: LLM
Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for this, and for the power numbers across the four controllers on the J616c.

One change before it goes in. We select behaviour by a hardware property, not by the chips it was tested on:

  • drivers/usb/typec/tipd/spmi.c:815-816: sn->idle_sleep = !sn->polled && (sn->select_polled || of_machine_is_compatible("apple,t6041"));

The property that matters is the one your comment names: the controller's event interrupt stays live while it sleeps. As written, the M4 Pro (T6040, same SN201202x controllers) and later chips stay awake only because they were not on the bench.

Suggested shape: describe it in the DT (for example a boolean on the SN201202x node such as apple,event-irq-in-sleep), set it in the SoC/board .dtsi files where it holds, and key idle_sleep on that property instead of the SoC compatible. If you believe it holds for every SN201202x that has an event interrupt, making that the default is even simpler.

Either way, we can run idle-sleep and hot-plug rows on our M4 Pro and A18 Pro, and on the M1 Pro and M2 where these controllers apply.

Whether an SN201202x can sleep while its port is idle depends on one
thing: its event interrupt stays live while the controller sleeps, so a
plug or other port event still reaches the host. Describe that with a
boolean on the controller node, so the driver doesn't have to know
which SoCs it was seen on.

Assisted-by: LLM
Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
On the J616c all four SN201202x (1-08, 1-0a, 1-0c, 2-0c) runtime-suspend
while idle, and a USB device plugged in while all four slept was
detected: the event interrupt stays live while they sleep. Mark every
SN201202x node of the T6041 boards with apple,event-irq-in-sleep, which
is where the driver turns idle sleep on today by the "apple,t6041"
machine compatible: the J614c and J616c (shared file) and the J575c's
four ports. Only the J616c was measured.

The driver reads the property from the next commit on.

Assisted-by: LLM
Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
Idle sleep needs only the event interrupt to stay live while the
controller sleeps. Key it on the node's apple,event-irq-in-sleep
instead of of_machine_is_compatible("apple,t6041"). T8132's
select-polled controllers keep it as before, since their system sleep
filter already depends on the same thing.

The T6041 boards' nodes have the property, so nothing changes on them,
and every other board stays awake as before. Another SoC with the same
controllers (the M4 Pro, say) gets idle sleep by setting the property
once its rows show the interrupt holds.

Assisted-by: LLM
Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Thanks. It now uses the DT property you suggested, in three new commits:

  • dt-bindings: apple,event-irq-in-sleep (boolean) on the SN201202x node. It means the controller's event interrupt stays live while the controller sleeps.
  • dts: the property is set on every SN201202x of the T6041 boards: the four on the J614c and J616c (shared file) and the four on the J575c. That's exactly the set the machine check covered.
  • tipd: sn->idle_sleep follows the property instead of of_machine_is_compatible("apple,t6041"). T8132's select-polled controllers keep idle sleep as before, because their system-sleep filter already depends on the same thing. The comment at the assignment says so.

So nothing changes on T6041 or anywhere else. I can't say whether it holds for every SN201202x with an event interrupt, because I've only measured the J616c. If your M4 Pro and A18 Pro rows show that a plug is still seen while the controllers sleep, the property can go into those boards' files in a follow-up, or become the default.

Tested: spmi.o and sn201202x-pm-test.o build with LLVM=1 W=1 with no warnings. The J614c, J616c and J575c DTBs build, and CHECK_DTBS gives no new warnings against the previous head. dt_binding_check passes for apple,sn201202x.yaml. The built DTBs have the property on all eight SN201202x nodes and on nothing else. tools/asahi/run-host-tests.py passes, 319/319. I haven't booted this head; the idle-sleep path it selects is the one measured in the description.

@DjDeveloperr, a gentle re-ping: your system-sleep point is addressed in 479d42a (option 2: idle sleep has its own flag, and T6041's system sleep path is as in integration/aurora). Could you take another look when you have time? Thanks.

Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested as described.

@AxxzyWasTaken AxxzyWasTaken changed the title usb: typec: tipd: sn201202x: sleep while idle on T6041 too usb: typec: tipd: sn201202x: idle sleep where the DT says the event IRQ stays live Nov 19, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, apple,event-irq-in-sleep on the SN201202x nodes is a clean way to describe this, and it drops the machine check. We will run idle-sleep and hot-plug rows on our M4 Pro and A18 Pro so the property can be set on those boards too.

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.

3 participants