Skip to content

Input: ft3658 - review fixes: DMA-safe buffers, fsleep(), the Google source - #133

Merged
derekross merged 3 commits into
derekross:omamobilefrom
nesmeck:omamobile-input-ft3658-fixes
Nov 1, 2026
Merged

derekross merged 3 commits into
derekross:omamobilefrom
nesmeck:omamobile-input-ft3658-fixes

Conversation

@nesmeck

@nesmeck nesmeck commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #109, one commit per review suggestion, each with Suggested-by: Derek Ross:

  • DMA-safe SPI buffers. tx and rx move after every other field in struct ft3658, each __aligned(ARCH_DMA_MINALIGN), as salixp.c does. The SPI API requires DMA-safe transfer buffers (include/linux/spi/spi.h, Documentation/spi/spi-summary.rst). On gs201 the USI SPI has no dmas and runs in polling mode, so nothing changes on the Pixel 7.
  • fsleep() instead of udelay(). The 150 µs CS-high delay now sleeps instead of spinning. ft3658_read() only runs from probe and the threaded interrupt handler.
  • The Google source in the header: kernel/google-modules/touch/focaltech_touch, ft3658/, branch android-gs-pantah-6.1-android16. focaltech_spi.c is the source for the framing, the status check, the 64-byte alignment rule and the CS-high delay, and focaltech_core.c for the power sequence and the report. The commit message says the same.

There's no functional change beyond the first two, and the driver is still read-only (no flash writes).

Tested on a Pixel 7 (slot B, 7.3.0-rc6), on today's omamobile (b0d62d9), with the USB bus PR on top. I ran one boot with the previous head (fdc4f4403), then one that changed only the alignment (7.3.0-rc6-omamobile-push1-gfe29f1dadbb5). In both:

  • focaltech_ft3658 loads at boot and reads chip id 0x56, firmware 0x16;
  • it reports touches across the panel, and the PIN unlock works;
  • dmesg shows no SPI or CRC errors.

Checks: tools/kernel-pr-check --build OUT --merge origin/omamobile passes everything:

  • a clean merge onto b0d62d9;
  • the sign-offs;
  • checkpatch --strict with no warnings;
  • the W=1 build of the driver.

🤖 Generated with Claude Code

@derekross

Copy link
Copy Markdown
Owner

Thank you, @nesmeck, for taking all three suggestions, one commit each. The citation in the header checks out: focaltech_spi.c on android-gs-pantah-6.1-android16 has the 150 µs CS-high delay, the 64-byte alignment rule and the rxbuf[3] & 0xA0 check. fsleep() is right too: both callers may sleep, and it never waits less than 150 µs. It builds clean with W=1, and checkpatch has nothing to say.

I owe you a correction, because the first commit repeats two things I got wrong on #109:

  1. The commit message's reason. I said the 90-byte report is long enough for the Exynos SPI driver to use DMA. On our tree it never DMAs: gs201.dtsi's spi_0 has no dmas property, so spi-s3c64xx runs in polling mode (sci->polling = !of_property_present(dev->of_node, "dmas")). Stock does use DMA (Google's gs201-panther-touch.dtsi adds dmas = <&pdma0 0 &pdma0 1>), which is where my sentence came from. The change is still right, just for a different reason: the SPI API requires DMA-safe tx_buf/rx_buf whatever the controller does (include/linux/spi/spi.h, and "must be DMA-safe" in Documentation/spi/spi-summary.rst). Since kernel PRs land commit by commit, could you reword d7700cb along those lines? For example: "SPI transfer buffers must be DMA-safe (spi.h), and a controller with a DMA channel would map them; on gs201 the USI SPI runs without DMA, so this changes nothing on the Pixel 7."
  2. Optional: the alignment. I suggested ____cacheline_aligned, but on arm64 that is 64 bytes while ARCH_DMA_MINALIGN is 128, so tx can still share a 128-byte granule with report[]. __aligned(ARCH_DMA_MINALIGN) is the exact form, and salixp.c in this tree uses it. Many input drivers do use ____cacheline_aligned, and with no DMA here it makes no difference today, so take it or leave it.

Once the message is reworded, this is ready to merge, before #134, since your touch test ran with it. Sorry for sending you the wrong reason the first time.

SPI transfer buffers must be DMA-safe (include/linux/spi/spi.h,
Documentation/spi/spi-summary.rst), and tx and rx sit in struct ft3658
next to other fields, so a controller with a DMA channel would map
memory those fields share. Put each buffer on its own ARCH_DMA_MINALIGN
boundary, after every other field. On gs201 the USI SPI has no DMA
channel and runs in polling mode, so this changes nothing on the
Pixel 7.

Tested on a Pixel 7 (7.3.0-rc6) with the touch node: the controller
probes (chip id 0x56, firmware 0x16) and reports touches across the
panel with no CRC errors.

Suggested-by: Derek Ross <derekross@gmail.com>
Assisted-by: Claude Opus 5.5
Signed-off-by: Alejandro Garcia <skipper.pelygro@gmail.com>
The controller needs chip select high for 150 us between transfers, and
ft3658_read() runs only from probe and the threaded interrupt handler,
both of which can sleep. Use fsleep() rather than spinning in udelay()
on every transfer.

Tested on a Pixel 7 (7.3.0-rc6) with the touch node: the controller
probes (chip id 0x56, firmware 0x16) and reports touches across the
panel with no CRC errors.

Suggested-by: Derek Ross <derekross@gmail.com>
Assisted-by: Claude Opus 5.5
Signed-off-by: Alejandro Garcia <skipper.pelygro@gmail.com>
The header says the protocol follows Google's GPL FocalTech driver for
Pixel devices. Name the repository, the directory, the branch and the
files, so a reviewer can follow it to the source: focaltech_spi.c for
the framing, the status check, the 64-byte alignment rule and the CS-high
delay, and focaltech_core.c for the power sequence and the report.

Suggested-by: Derek Ross <derekross@gmail.com>
Assisted-by: Claude Opus 5.5
Signed-off-by: Alejandro Garcia <skipper.pelygro@gmail.com>
@nesmeck

nesmeck commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the correction. The reason you gave first was a fair reading of stock. I force-pushed (c87796f67):

  1. The reason. The first commit (now 0aff2501f) says what you suggested. SPI transfer buffers must be DMA-safe, and a controller with a DMA channel would map memory the other fields share. On gs201 the USI SPI runs in polling mode, so nothing changes on the Pixel 7.
  2. The alignment. I took __aligned(ARCH_DMA_MINALIGN) for both buffers, with <linux/cache.h>. Your other two commits are unchanged.

Tested on the Pixel 7 on today's omamobile (b0d62d9), one change per boot: first the previous head, then only this change. Touch, the PIN unlock and the haptics work, with no SPI or CRC errors. kernel-pr-check passes. The PR description has the details.

About #134, which landed before this one:

I also opened #167, which enables the MAX77759's I2C bus so omamobile-usb-rescue can bring USB back after a replug.

🤖 Generated with Claude Code

@derekross

Copy link
Copy Markdown
Owner

Thank you, @nesmeck, for rewording the first commit and for taking __aligned(ARCH_DMA_MINALIGN) too.

I compared the new head with the one I commented on: the only changes are the first commit's message and the two alignment lines (plus <linux/cache.h>); the other two commits are the same as before. The new message gives the right reason (the SPI API's DMA-safe rule, and no DMA on gs201 today), the trailers parse as one block, and the struct now ends on a 128-byte boundary, so neither buffer shares a granule with another field.

I re-ran our gate on today's omamobile: it merges cleanly, the sign-offs and prefixes pass, checkpatch has nothing to say, and the driver builds clean with W=1. CI is green on this head as well. Your Pixel 7 boot with only the alignment change covers what changed.

Nothing more needed from you. I'll merge it as it is.

@derekross
derekross merged commit 64605e4 into derekross:omamobile Nov 1, 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