[PATCH] HID: intel-thc-hid: intel-thc: rewrite PRD tables on reset

From
Emfox Zhou <hidden>
Date
2026-11-14 23:18:14
Also in
lkml
RxDMA reset takes the DMA configuration down and puts it back, but leaves
the PRD entries as the controller wrote them. A frame that was queued and
not read keeps its shortened length, so the next frame runs past the end of
the table: the controller reports a buffer overrun, which is a transfer
error and leads back into the same reset, with the tables still untouched.

Write the receive tables again while both engines are paused, before the
configuration starts them. The configuration is the wrong place for it: on
resume it runs with a frame that arrived before the suspend still queued.

Signed-off-by: Emfox Zhou <redacted>
---
 drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c | 7 +++++++
 1 file changed, 7 insertions(+)
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 c80ef8c20..28a1aa97b 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
@@ -211,6 +211,9 @@ static void thc_copy_sgls_to_prd(struct thc_device *dev,
 {
 	unsigned int i;
 
+	if (!config->is_enabled)
+		return;
+
 	memset(config->prd_tbls, 0, array_size(PRD_TABLE_SIZE, config->prd_tbl_num));
 
 	for (i = 0; i < config->prd_tbl_num; i++)
@@ -598,6 +601,10 @@ int thc_rxdma_reset(struct thc_device *dev)
 
 	thc_dma_unconfigure(dev);
 
+	/* Still paused: the configuration starts the receive engine again. */
+	thc_copy_sgls_to_prd(dev, &dev->dma_ctx->dma_config[THC_RXDMA1]);
+	thc_copy_sgls_to_prd(dev, &dev->dma_ctx->dma_config[THC_RXDMA2]);
+
 	ret = thc_dma_configure(dev);
 	if (ret) {
 		dev_err(dev->dev, "Re-config DMA failed during RxDMA reset\n");
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
Thread (2 messages) 2 messages, 2 authors, last reply 6d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help