Linux Input/HID development
 help / color / mirror / Atom feed
From: Even Xu <even.xu@intel.com>
To: bentiss@kernel.org, jikos@kernel.org
Cc: srinivas.pandruvada@linux.intel.com, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org, Even Xu <even.xu@intel.com>,
	Rui Zhang <rui1.zhang@intel.com>
Subject: [PATCH 4/4] HID: Intel-thc-hid: Intel-thc: Restore RXDMA after SWDMA operation errors
Date: Mon, 16 Nov 2026 16:28:00 +0800	[thread overview]
Message-ID: <20261116082805.3986615-5-even.xu@intel.com> (raw)
In-Reply-To: <20261116082805.3986615-1-even.xu@intel.com>

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@intel.com>
Tested-by: Rui Zhang <rui1.zhang@intel.com>
---
 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


      parent reply	other threads:[~2026-11-16  8:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  8:27 [PATCH 0/4] Fix potential THC DMA issues Even Xu
2026-11-16  8:27 ` [PATCH 1/4] HID: Intel-thc-hid: Intel-thc: Add safe DMA read interfaces Even Xu
2026-11-16  8:27 ` [PATCH 2/4] HID: Intel-thc-hid: Intel-quickspi: Use safe RXDMA reads Even Xu
2026-11-16  8:27 ` [PATCH 3/4] HID: Intel-thc-hid: Intel-quicki2c: Use safe DMA reads Even Xu
2026-11-16  8:28 ` Even Xu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116082805.3986615-5-even.xu@intel.com \
    --to=even.xu@intel.com \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rui1.zhang@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox