Skip to content

HID: intel-thc-hid: intel-thc: DMA lifetime fixes

Emfox Zhou linux-input lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 0 repliesNew
  2. v15 patches 0 repliesSuperseded

Changes in v2 from the cover letter

- Patch 5 waits for the four engines in thc_dma_unconfigure() before the tables go away, and is renamed from "budget the receive drain" to "budget the engine drain" to cover the transmit side as well. The budget it adds is named THC_DMA_DRAIN_US_TIMEOUT for the same reason.
- Patches 1 to 4 are unchanged in code.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5HID: intel-thc-hid: intel-thc: keep TxDMA write errorsdrivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c+6 -50 replies
2/5HID: intel-thc-hid: intel-thc: free the failed channeldrivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c+7 -80 replies
3/5HID: intel-thc-hid: intel-thc: stop all engines firstdrivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c+19 -140 replies
4/5HID: intel-thc-hid: intel-thc: add the slow SPI gearsdrivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c+35 -80 replies
5/5HID: intel-thc-hid: intel-thc: budget the engine draindrivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.h+61 -170 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/5] HID: intel-thc-hid: intel-thc: DMA lifetime fixes

This series fixes the DMA lifetime problems a protocol driver above the THC core cannot work around, plus two smaller issues next to them.

Patch 1 makes thc_dma_write() report the error it found instead of overwriting it with the result of the interrupt restore, and stops a signal from turning a committed transfer into a restartable one. The completion interrupt has to wake the queue with wake_up(), because the new wait is uninterruptible.

Patch 2 unwinds a failed allocation through thc_dma_release(), so the channel whose setup failed is freed too, and frees a scatter-gather list that was allocated but never mapped.

Patch 3 stops all four engines before thc_dma_unconfigure() clears their PRD base addresses; only the two receive engines are stopped today.

Patch 4 adds the low frequency SPI gears, down to 2.23 MHz.

Patch 5 gives the engines a drain budget that covers a full frame at that gear, and leaves the SWDMA path on the old one. thc_dma_unconfigure() waits for the engines with the same budget before its caller releases the tables: a start clear is only a request, and an engine still writing would reach pages that are already back in the allocator.

These apply to v7.4-rc3. They are independent of the PRD table capacity fix posted separately; the two are both needed for the recovery path to be complete, but neither depends on the other.

Link to v1: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Patch 5 waits for the four engines in thc_dma_unconfigure() before the tables go away, and is renamed from "budget the receive drain" to "budget the engine drain" to cover the transmit side as well. The budget it adds is named THC_DMA_DRAIN_US_TIMEOUT for the same reason.
- Patches 1 to 4 are unchanged in code.

Emfox Zhou (5):
HID: intel-thc-hid: intel-thc: keep TxDMA write errors
HID: intel-thc-hid: intel-thc: free the failed channel
HID: intel-thc-hid: intel-thc: stop all engines first
HID: intel-thc-hid: intel-thc: add the slow SPI gears
HID: intel-thc-hid: intel-thc: budget the engine drain

 .../intel-thc-hid/intel-thc/intel-thc-dev.c   |  45 +++++--
 .../intel-thc-hid/intel-thc/intel-thc-dma.c   | 127 ++++++++++++------
 .../intel-thc-hid/intel-thc/intel-thc-dma.h   |   5 +
 3 files changed, 126 insertions(+), 51 deletions(-)

base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3