Skip to content

clk: samsung: zumapro: Keep the PERIC0 GPIO bus clock on (Pixel 9a modem hang) - #172

Merged
derekross merged 2 commits into
derekross:omamobilefrom
W4HO-ham:tegu-peric0-gpio-clk
Nov 2, 2026
Merged

derekross merged 2 commits into
derekross:omamobilefrom
W4HO-ham:tegu-peric0-gpio-clk

Conversation

@W4HO-ham

@W4HO-ham W4HO-ham commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Base: omamobile. One commit, one file. It still needs my sign-off before merge.

What

CLK_GOUT_GPIO_PERIC0 goes from CLK_IGNORE_UNUSED to CLK_IS_CRITICAL, so the clock framework keeps the PERIC0 GPIO block's bus clock on.

Why

This is the Pixel 9a hang that killed every GNSS session with the modem up (MODEM-PLAN G3-L1 on #202).

  • The PERIC0 GPIO gate is the only writable GPIO gate in clk-zumapro.c. The APM and PERIC1 GPIO gates are read-only gates.
  • It runs in manual mode. On the palmtop, CLK_CON_GAT 0x20b8 reads 0x100000 between accesses: MANUAL set, CG_VAL clear, automatic gating off.
  • The Samsung pin controller enables its pclk around every register access and disables it after, so every GPIO write on PERIC0 switches the gate on and off.
  • The modem's AP2CP lines (wakeup, PDA active, reset, power) are on PERIC0 banks (gpp8, gpp12, gpp16). During GNSS the CP powers its PCIe link down and up about twice a second, and cpif writes those lines each time.

Every session before this reset the palmtop by watchdog, after 37 to 1083 link cycles. The last kernel line moved from run to run: a config read, a doorbell, a DBI read, after the link had gone down. One run's pstore showed the SoC stalling piece by piece: Wi-Fi, then the APM's ACPM channel, then five CPUs in an RCU stall.

Testing

Pixel 9a, 7.3.0-rc6-omamobile-tegu-s2mpg15-m1, 600 s GNSS sessions with the CP ONLINE:

Run Clock Link power cycles Result GNSS fixes
10 earlier sessions (traces, CPU idle off, PHY isolation off) gated per access 37 to 1083 reset every time
hold 1 held on by a bring-up module 1325 no reset 550 of 557
hold 2 held on by a bring-up module 1326 no reset 558 of 564
this commit, run 1 critical 1335 no reset 568 of 570
this commit, run 2 critical 1333 no reset 558 of 567
this commit, 30 min critical 3759 no reset 1763 of 1765

After boot with this commit, clk_enable_count is 1 and the gate register reads 0x300000 (CG_VAL set).

tools/kernel-pr-check: checkpatch --strict clean, policy clean; only the sign-off is missing.

@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham. This is a lovely piece of detective work. The table makes the case well: ten sessions that all reset, two runs with the clock held by a module, then three runs with this commit, the longest 3759 link cycles with no reset. The register reads line up too: 0x100000 is MANUAL with CG_VAL clear, and 0x300000 with this change is MANUAL with CG_VAL set. And holding a clock on that the pin controller would otherwise switch off after every access is a small, contained fix. It only touches clk-zumapro.c, so no other phone is affected.

What I checked: the gate passes on today's omamobile (it merges cleanly, the subject prefix is right, checkpatch --strict is clean, the identifier check is clean, and clk-zumapro.c builds with W=1). The one failure, here and in CI, is the missing Signed-off-by:, as you said.

Two things before it merges:

  1. "The only writable GPIO gate" isn't quite right. The APM, HSI1 and PERIC1 GPIO gates are read-only gates, yes, but CMU_HSI2 registers two writable GPIO gates in hsi2_gates[]: CLK_GOUT_GPIO_HSI2UFS (0x2008) and CLK_GOUT_GPIO_HSI2 (0x2060). They're the clocks of pinctrl_hsi2ufs and pinctrl_hsi2 in zumapro.dtsi, so the pin controller switches them on and off around every access in exactly the same way. On the 9a that includes the Wi-Fi's PERST# and WL_REG_ON on gph3 once Wi-Fi is in the DT. Those lines don't toggle twice a second, so they may never hit this. But if the hang comes from closing a manual gate right behind a posted GPIO write, it isn't specific to PERIC0. Could you read the two HSI2 CLK_CON_GAT registers on the palmtop the same way you read 0x20b8, one register per read? Then either mark them critical too (in this commit or a second one), or say in the message why they're different. Either way, please correct the sentence in the commit message and the comment. With a rebase merge, the message lands as written.

  2. The sign-off, once the message is settled.

A small suggestion for the message, if you know it: say what stock does with this clock. If Google's pin controller never gates the GPIO bus clock, "keeping it on matches stock" is the strongest reason this is safe. If you don't know, leave it out.

Once those are in and CI is green, I'll merge it.

The PERIC0 GPIO gate is writable and in manual mode (CLK_CON_GAT 0x20b8
reads 0x100000: MANUAL set, automatic clock gating off). The Samsung
pin controller enables its pclk around every register access and
disables it afterwards, so each GPIO write on the block turns the gate
on and off. Stock never does this: its device tree gives zumapro's pin
controllers no clocks, so Google's pin controller never switches
the GPIO bus clocks off.

On the Pixel 9a the modem's AP2CP control lines are on this block and
toggle on every PCIe link power cycle, about twice a second during a
GNSS session. With the gate toggling, the SoC hung within 37 to 1083
link cycles in every session, at varying points, with no kernel error
and a watchdog reset. With the clock held on (a bring-up module taking
a reference) two 600 s sessions ran 1325 and 1326 link cycles each with
no hang, and the same result followed with this change in the kernel.

Mark the gate critical so the clock framework keeps it enabled.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
CMU_HSI2's two GPIO gates, for pinctrl_hsi2ufs (0x2008) and pinctrl_hsi2
(0x2060), are writable and in the same manual mode as PERIC0's: on the
Pixel 9a both CLK_CON_GAT registers read 0x100000 (MANUAL set, CG_VAL
clear), and the clock summary shows them at enable count 0 between pin
controller accesses. So the pin controller turns them on and off around
every access, as it did PERIC0's.

No hang has been seen on these blocks: their lines (the Wi-Fi's PERST#
and WL_REG_ON on gph3, the UFS pins) change rarely. But the PERIC0 hang
followed the gate toggling, not anything specific to that block, and
stock's pin controllers name no clocks, so Google's kernel never gates
any GPIO bus clock. Mark both gates critical as well.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@W4HO-ham
W4HO-ham force-pushed the tegu-peric0-gpio-clk branch from c36e4f4 to 52da429 Compare November 2, 2026 15:45
@W4HO-ham

W4HO-ham commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, Derek. You were right about the sentence, and the reads back you up.

The HSI2 gates. I read both on the palmtop, one register per read, as I did 0x20b8:

Register Gate Value
0x13002008 CLK_GOUT_GPIO_HSI2UFS 0x00100000
0x13002060 CLK_GOUT_GPIO_HSI2 0x00100000
0x108020b8 CLK_GOUT_GPIO_PERIC0 (with this PR's first commit) 0x00300000

Both HSI2 gates are MANUAL with CG_VAL clear, the same state PERIC0's was in before the fix, and the clock summary shows them at enable count 0 between pin controller accesses. So the pin controller toggles them exactly as it toggled PERIC0's. No hang has been seen on those blocks, but their lines change rarely, and the PERIC0 hang followed the toggling rather than anything about that block. So I've marked them critical too, in a second commit: "clk: samsung: zumapro: Keep the HSI2 GPIO bus clocks on too".

What stock does. Stock's zumapro device tree gives its pin controllers no clocks at all (pinctrl@10840000, pinctrl@13040000 and the rest in zumapro.dtsi have only compatible, reg and interrupts), so Google's pin controller never switches a GPIO bus clock off. I've added that to the first commit's message.

The message. "The only writable GPIO gate" is gone: it now says the PERIC0 gate is writable and in manual mode, and adds the stock note.

Checks. Both commits are signed off now. W=1 builds of clk-zumapro.c at each commit have no warnings, and tools/kernel-pr-check --merge against omamobile 91d3f15 passes (merges cleanly, prefixes, checkpatch --strict clean, identifiers, W=1).

What hasn't run yet: a palmtop kernel with the HSI2 commit. The first commit is the one the GNSS sessions ran on. I'll boot the second with the next test kernel and add the clock summary here.

@W4HO-ham

W4HO-ham commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

The HSI2 commit has now run on the palmtop: a kernel with both commits from this PR (7.3.0-rc6-omamobile-push1-g909c8c8121bb, built for #186's test) shows all three GPIO bus clocks held on, where this morning's kernel had the two HSI2 ones at enable count 0:

zumapro_gpio_hsi2      1  2  0  266496000  ...  Y  13040000.pinctrl  pclk
zumapro_gpio_hsi2ufs   1  2  0  266496000  ...  Y  13060000.pinctrl  pclk
zumapro_gpio_peric0    1  2  0   66624000  ...  Y  10840000.pinctrl  pclk

On that boot the Wi-Fi (its PERST# and WL_REG_ON are on the HSI2 block) came up and came back after three rebinds, and UFS logged no errors.

@derekross
derekross merged commit 4cf2c8b into derekross:omamobile Nov 2, 2026
1 check passed
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.

2 participants