Repository navigation
Conversation
…uffer sg_copy_to_buffer() walks the CPU-side scatterlist, so it needs the number of pages passed to dma_map_sg(), not the number of mapped entries that calc_message_len() derives from the PRD table. With an IOMMU, dma_map_sg() can merge pages, so the PRD table holds fewer entries than the scatterlist has pages. The copy then stops early (e.g. "Copied 4096 bytes instead of requested 7492") and the read fails with -EIO, which leaves the touch controller stuck when a stylus sends large reports. Use the page count stored in sgls_nent_pages[] instead. Fixes: a688404 ("HID: intel-thc-hid: intel-thc: Add THC DMA interfaces") Link: linux-surface/linux-surface#2261 Patchset: intel-thc Signed-off-by: technosf <535060+technosf@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs linux-surface/linux-surface#2261.
sg_copy_to_buffer()walks the CPU-side scatterlist, so it needs the number ofpages passed to
dma_map_sg(), not the number of mapped entries thatcalc_message_len()derives from the PRD table. With an IOMMU,dma_map_sg()can merge pages, so the PRD table holds fewer entries than the scatterlist has
pages. The copy then stops early ("Copied 4096 bytes instead of requested
7492") and the read fails with -EIO, which leaves the touch controller stuck
when a stylus sends large reports.
The patch uses
sgls_nent_pages[], which already stores the page count: aone-call change (2 lines added, 1 removed) in
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c. The change is the oneproposed by @ffaon in #2261.
Other callers checked:
write_dma_buffer()also usessg_copy_from_buffer(),but it computes its count from the message length (
DIV_ROUND_UP(len, 4K)),and the CPU-side list has one page per entry (
sgl_alloc()), so it does nothave this problem and is unchanged.
Tested on a Surface Pro 10 for Business with a 7.2 kernel and this patch
applied: multitouch and stylus work.