Skip to content

spi: s3c64xx: turn the channels off before clearing the packet count - #150

Merged
derekross merged 1 commit into
derekross:omamobilefrom
W4HO-ham:spi-s3c64xx-flush-order
Oct 31, 2026
Merged

derekross merged 1 commit into
derekross:omamobilefrom
W4HO-ham:spi-s3c64xx-flush-order

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

s3c64xx_flush_fifo() clears PACKET_CNT, and with it PACKET_CNT_EN, while RXCH_ON is still set. For the length of that write the controller receives with no packet count and runs SCK freely; with automatic chip select the slave stays selected and shifts out bits the flush then discards. Google's driver for this controller turns the channels off first. This does the same, one write moved.

Slaves that restart on every chip-select cycle (the touchscreens) don't notice. The Pixel 9a's GNSS core streams CHPP across cycles and lost two to six bits per transfer: every read arrived at a different bit offset and frames that crossed reads failed their CRC. This was the GNSS link problem tracked on #137 since 10-28.

Tested on the palmtop (the 9a), on the integration kernel with this commit and the GNSS SPI's swap-mode and pin settings from #137: every CHPP read at bit 0 with a valid CRC32, and a 10-minute GNSS session with 38 of 43 GGA sentences fixed (10-13 satellites, HDOP about 1), no ACK timeouts, bad checksums or link errors. The touchscreen on the other PERIC1 SPI bus and the rest of the smoke report were unchanged on the same boot. Not tested on the Pixel 7 Pro; its SPI users there (touch) restart per transfer, so no change is expected, but a boot with touch working would confirm it.

checkpatch --strict: 0 errors, 0 warnings.

@derekross

Copy link
Copy Markdown
Owner

Thank you for tracking this down. Google's Pixel 7 driver does the same in flush_fifo(), so I agree it's a real fix. It runs on every transfer on every Exynos SPI controller, though, and the 7 Pro has three SPI users (touch, both speaker amplifiers and GNSS), so I'll merge it once I've run it on my phone. Could you add a Link: to Google's file, pinned to a commit? Nothing else is needed from you.

s3c64xx_flush_fifo() clears PACKET_CNT, and with it PACKET_CNT_EN, while
RXCH_ON is still set. For the duration of that write the controller is
receiving with no packet count, so it runs SCK freely; with automatic
chip select the slave stays selected and shifts out bits that the flush
then throws away.

Slaves that restart their protocol on every chip-select cycle don't
notice. A slave that streams across cycles does: the Pixel 9a's GNSS
core, which talks CHPP over this controller, lost two to six bits per
transfer, so every read arrived at a different bit offset and frames that
crossed reads failed their CRC. With the channels turned off first, as
Google's driver for this controller does, every read arrives at bit 0
with a valid CRC and the receiver gets a fix.

Turn RX and TX off before clearing the packet count.

Link: https://android.googlesource.com/kernel/google-modules/soc/gs/+/204078758737776959ecc85c527a00fd2cabb62f/drivers/spi/spi-s3c64xx.c
Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Added the Link: to Google's file, pinned to the google-modules soc/gs commit 204078758737776959ecc85c527a00fd2cabb62f (the June 2025 sync, which is the tree I compared against; its flush_fifo() turns the channels off before clearing the count). Nothing else changed; the sign-off is unchanged and checkpatch is clean.

@W4HO-ham
W4HO-ham force-pushed the spi-s3c64xx-flush-order branch from e6c971d to badc176 Compare October 31, 2026 15:55
@derekross
derekross merged commit 51fb40d into derekross:omamobile Oct 31, 2026
1 check passed
@derekross

Copy link
Copy Markdown
Owner

Tested on my 7 Pro on 7.3.0-rc6-omamobile-push1-gc32dd8e2d33e (my test kernel plus this commit): all three SPI users run with no SPI errors. Touch works; GNSS streamed about 5,300 NMEA lines over 150 s with no errors; both speaker amplifiers came up with protection and played tones on each speaker and both, with no amplifier errors and no watchdog mute. Merged, thanks. The Link: to Google's file can come with your next SPI change.

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