[PATCH 4/4] HID: Intel-thc-hid: Intel-thc: Restore RXDMA after SWDMA operation errors

From: Even Xu

Date: Mon Nov 16 2026 - 03:28:04 EST


thc_swdma_read_start() quiesces device interrupts, stops RXDMA and
temporarily disables the I2C special controls. If reading the response
of a completed SWDMA transfer fails, thc_swdma_read_safe() skips
thc_swdma_read_completion(), leaving RXDMA stopped and the saved I2C
controls unrestored. Normal input processing can no longer resume.

Call thc_swdma_read_completion() even when reading the completed
response fails, so RXDMA and the saved I2C controls can be restored.

Fixes: a688404b2e20 ("HID: intel-thc-hid: intel-thc: Add THC DMA interfaces")
Signed-off-by: Even Xu <even.xu@xxxxxxxxx>
Tested-by: Rui Zhang <rui1.zhang@xxxxxxxxx>
---
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c
index 11d29c8daebe..7f9c9017049c 100644
--- a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c
+++ b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c
@@ -911,6 +911,7 @@ static int thc_swdma_read_completion(struct thc_device *dev)
* @read_len: The pointer of the read data length
*
* Oversized frames are discarded without copying data and @read_len is zero.
+ * The completed transaction is restored before returning the read error.
*
* Return: 0 on success, other error codes on failed.
*/
@@ -949,12 +950,11 @@ int thc_swdma_read_safe(struct thc_device *dev, void *write_buff, size_t write_l

ret = thc_dma_read(dev, &dev->dma_ctx->dma_config[THC_SWDMA],
read_buff, read_buff_len, read_len, NULL);
- if (ret)
- goto end;
-
- ret = thc_swdma_read_completion(dev);

end:
+ if (thc_swdma_read_completion(dev))
+ dev_err(dev->dev, "Failed to restore DMA after SWDMA read\n");
+
mutex_unlock(&dev->thc_bus_lock);
return ret;
}
--
2.43.0