Repository navigation
clk: samsung: zumapro: Keep the HSI0 USI2 and USI3 clocks on - #247
Conversation
The gates of USI2 and USI3 in the HSI0 block (the bus, function and source clock of each) are writable and in manual mode, and nothing holds them while the SPI controllers behind them are idle. A register access to the USI in the first microseconds after its gates are opened never returns: the CPU sits in the access, takes no tick and answers no IPI. The USI driver does that in its noirq resume (clk_bulk_prepare_enable(), then USI_CON read and written), and so on the Pixel 9a a sleep now and then never woke. Two such hangs were caught with the device callback trace events on. In the first, at the 41st sleep of a boot, the suspend task's last event is device_pm_callback_start for the USI at 111d00c0 (USI2, the touchscreen's SPI), with no end. In the second, on a kernel that kept only the two bus clocks on, USI2's callback returns and the last event is the start of USI3's, at 111e00c0, at the 227th sleep. The USIs resumed before them, in PERIC0 and PERIC1, have read-only gates, and so has USI4 in HSI0. It reproduces awake in under a second. A test module that repeats the driver's sequence on USI3 (clocks on, USI_CON read and written, 1 us, clocks off), with the bus clock already on and only the function clock switched, hung the SoC within its first thousand rounds, twice of twice, until the watchdog reset it. With 10 us between the clocks and the access, two million rounds passed, and so did two million rounds that switched the clocks and touched no register. Mark the six gates critical, as the PERIC0 and HSI2 GPIO gates are, so the clock framework never closes them. With that, on the published tree with nothing else added, two million rounds of the same module passed on each USI with the gates never closed. Before it, with a module holding the two USIs' clocks on, 300 of 300 sleeps of 60 s woke on the build that had hung at the 70th and the 41st. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
|
Thank you, @W4HO-ham. This is a careful piece of detective work. Catching the hang in the PM callback trace, then turning a 1-in-a-few-hundred sleep failure into a sub-second reproduction that tells the cases apart (no wait: hung twice in 1,000 rounds; 10 µs wait or no register access: 2,000,000 clean), is exactly the evidence a clock change like this needs. It also explains the CPU 7 lockup we had recorded without a cause. I checked it against the base. Two things before I merge, both quick:
Two smaller things, not for this commit:
|
|
Thank you. Both are coming today.
The test module comes to |
|
The series is done: 300 of 300 sleeps of 60 s woke on this build (
For comparison, the same series without the fix stopped at the 70th, the 41st and (bus clocks only) the 227th sleep. The description has the count now. Touch and GNSS on this build are next, with the owner at the palmtop. |
|
Both checks on this build ( Touch (USI2), on the boot the 300 ran on, right after the series. The driver had probed as on the daily kernel ( GNSS (USI3), after a clean reboot with the modem up, kernel log streamed to the laptop from boot. One thing that is not the kernel: the first session attempt on that boot failed at once, because the palmtop's With the 300 of 300 above, that is everything you asked for here. The palmtop goes back to its daily kernel now. |
|
Hi @W4HO-ham, this was a good read, and it made me look at zuma, because the 8 Pro has the same two buses. On today's What I don't know is whether zuma hangs on it the way zumapro does. The only no-wake I've had on my 8 Pro was a deep suspend on 2026-11-12, which is a different path from s2idle, and I haven't seen one in s2idle, but I've only done a handful of those (eight successes by 2026-11-13 in my notes), far fewer than your roughly 1 in 300 needs, and I haven't run your stress module or anything like it. So this is from reading the source only, nothing tested. It matters for GNSS on the 8 Pro: stage 2 of my plan in derekross/omarchy-mobile#739 enables @derekross, would it be wanted for zuma as well, the six gates critical, as its own PR after this one? I can send it, but I could only test it on the 8 Pro, and not with a long sleep series yet. |
|
Thanks @Somnius, I read the same in One thing that may save you the long series: on the 9a the answer came awake, not from sleeps. The stress module in #800 ( It finds the USI by device-tree path and takes |
|
Thanks @W4HO-ham, that is a much better test than a long sleep series, and it makes the question testable in minutes. I haven't run it or built it for husky. Since it hangs the SoC by design, I won't run it unless @derekross says it's wanted, and then only attended: filesystems synced, a watchdog fed from userspace, the slot B retry count read first, and on a USI nothing else is using. On my unit that would be USI2 with the touchscreen unused, or USI3 after stage 2 of derekross/omarchy-mobile#739. I did the software-only reads on my unit instead (the clk debugfs enable counts and flags, and the SPI controllers' |
|
Thank you, both are in. The 300 of 300 on the published tip with only this commit, after the attended ten and against the same series stopping at the 70th, 41st and 227th without it, is the count I asked for. Touch in the session and a GNSS session with 104 of 109 fixes, no SPI errors, and the USI3 divider still following the session's rate, covers what I wanted from the two users. I re-ran our gate on today's Thank you also for putting the modules in the tree in #800. I've asked there for the stress module to refuse anything but a 9a and to have no default USI, since it hangs the SoC on purpose. @Somnius, thank you for reading zuma's side. I'll answer separately on whether I want the same change for zuma. Until then, please keep the stress module off your 8 Pro, as you said you would. |
On the Pixel 9a a sleep now and then never woke: four in about 1,200 on the published tree (omarchy-mobile#659, SLEEP-PLAN "What is left" item 1). This is the cause and the fix.
The cause. A register access to a USI in the first microseconds after its clock gates are opened never returns. The CPU sits in the access, takes no tick and answers no IPI. The gates of USI2 and USI3 in HSI0 are writable and in manual mode, nothing holds them while their SPI controllers are idle, and the USI driver's noirq resume opens them and reads
USI_CONat once. The USIs resumed before them, in PERIC0 and PERIC1, have read-only gates, and so has USI4 in HSI0. It is the shape #172 removed for the PERIC0 GPIO gate.How it was found.
Two hangs caught with the device callback trace events on. On 2026-11-12, at the 41st sleep of a boot, the suspend task's last event is
device_pm_callback_startfor the USI at 111d00c0 (USI2, the touchscreen's SPI), noirq resume, with no end.A first try at this change kept only the two PCLK gates on. On that kernel 226 sleeps woke and the 227th hung one callback further on: USI2's resume returns, and the last event is the start of USI3's, at 111e00c0. Its bus clock was on; what its resume switched was the function clock.
Awake, in under a second (11-13). A bring-up module repeats the driver's sequence on USI3 from a thread on CPU 7: clocks on,
USI_CONread and written back, 1 us, clocks off. On the PCLK-only kernel, so with only the function and source gates switched:APC Watchdog Early)That also fits the 701 clean sleeps with the function tracer on: it puts microseconds between the gate's write and the read.
The fix. All six gates (PCLK, IP and SOURCE of USI2 and USI3)
CLK_IS_CRITICAL, as the PERIC0 and HSI2 GPIO gates are, so the clock framework never closes them. A wait after the gate would do it too, but it would have to go into every path that opens one of these gates, and the tree's rule since #172 is that a CMU without automatic clock gating keeps such gates on.Tested on my palmtop, on the published tip (2db2bc3) with only this change, defconfig plus main's
omamobile.config, no debug switches:clk_enable_count1 or 2 andCLK_IS_CRITICALon all six gates.pm_wakeup_irq53 each, no UFS line). A series of 300 on the same boot followed, unattended (07:08 to 14:27 MST): 300 of 300 woke, each on the alarm (pm_wakeup_irq53), 59.2 to 60.3 s by the kernel log, no UFS line, no oops;suspend_statsreads success 310, fail 0 for the boot.synaptics-tcmon USI2's SPI) is bound.Not tested: the unchanged published tip under the module (the hangs above are on the tracing build of the same sources, with the PCLK gates kept on); touch itself on this build, beyond the driver being bound.
Who was there: the ten sleeps at the start of the series on this build were attended. The 300 with the module and the 226 on the PCLK-only kernel ran overnight with nobody at the palmtop, on a module and a kernel that had had no attended run, on my own say-so for my own palmtop; they don't count under the attended-first rule. The awake test resets the palmtop when it hangs; it ran in the morning with me near the palmtop, and the watchdog brought it back each time.
tools/kernel-pr-checkis clean.