mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] HID: intel-thc-hid: intel-thc: rewrite PRD tables on reset
@ 2026-11-14 23:17 Emfox Zhou
  0 siblings, 0 replies; only message in thread
From: Emfox Zhou @ 2026-11-14 23:17 UTC (permalink / raw)
  To: Even Xu, Xinpeng Sun, Jiri Kosina, Benjamin Tissoires
  Cc: linux-input, linux-kernel

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 <emfox@debian.org>
---
 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-14 23:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-14 23:17 [PATCH] HID: intel-thc-hid: intel-thc: rewrite PRD tables on reset Emfox Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®