Repository navigation
usb: typec: tipd: sn201202x: idle sleep where the DT says the event IRQ stays live - #1889
AxxzyWasTaken wants to merge 5 commits into
Conversation
DjDeveloperr
left a comment
There was a problem hiding this comment.
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 forpolled || select_polled;sn->atomiconly 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:
- Poll the select in the sleep-event path too, e.g.
if (sn->polled || sn->select_polled || sn->atomic)inregmap_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. - Enable only idle sleep on T6041: decouple
sn201202x_idle_sleep_start()/_stop()fromtps->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.
|
Thanks, you're right: setting I went with option 2 in 479d42a. A new 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. |
|
@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>
479d42a to
78ad8ef
Compare
|
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:
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 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>
|
Thanks. It now uses the DT property you suggested, in three new commits:
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: @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 Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested as described. |
|
Thanks, |
#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-0con 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:
apple,event-irq-in-sleep(boolean) on the SN201202x node: the controller's event interrupt stays live while it sleeps.sn->idle_sleepfollows 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 keepsenable_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.power/runtime_status= suspended).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.On this branch (the first commit alone on
integration/aurora5b36eff):spmi.obuilds with LLVM=1 W=1 with no warnings, and checkpatch is clean.The DT commits (19 Nov):
spmi.oandsn201202x-pm-test.obuild 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_checkpasses forapple,sn201202x.yaml. Each built DTB hasapple,event-irq-in-sleepon all four SN201202x nodes, and on no others.tools/asahi/run-host-tests.pypasses, 319/319.Not tested