mirror of https://lore.kernel.org/lkml/
 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 3/4] HID: Intel-thc-hid: Intel-quicki2c: Use safe DMA reads
Date: Mon, 16 Nov 2026 16:27:59 +0800	[thread overview]
Message-ID: <20261116082805.3986615-4-even.xu@intel.com> (raw)
In-Reply-To: <20261116082805.3986615-1-even.xu@intel.com>

Use thc_rxdma_read_safe() and thc_swdma_read_safe(). Pass
HIDI2C_PACKET_LEN(input_len) as the destination capacity for RXDMA input
reports and SWDMA GET_REPORT responses. Handle -EMSGSIZE in the receive
loop by continuing pending reports instead of scheduling full RXDMA
recovery.

Fixes: 66b59bfce6d9 ("HID: intel-thc-hid: intel-quicki2c: Complete THC QuickI2C driver")
Signed-off-by: Even Xu <even.xu@intel.com>
Tested-by: Rui Zhang <rui1.zhang@intel.com>
---
 drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c  | 9 ++++++---
 .../hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c | 7 ++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
index 29319b6227f3..f87f33f61d34 100644
--- a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
+++ b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
@@ -292,9 +292,12 @@ static int handle_input_report(struct quicki2c_device *qcdev)
 	int ret;
 
 	while (!rx_dma_finished) {
-		ret = thc_rxdma_read(qcdev->thc_hw, THC_RXDMA2,
-				     (u8 *)pkt, &report_len,
-				     &rx_dma_finished);
+		ret = thc_rxdma_read_safe(qcdev->thc_hw, THC_RXDMA2, (u8 *)pkt,
+					  HIDI2C_PACKET_LEN(qcdev->input_len), &report_len,
+					  &rx_dma_finished);
+		if (ret == -EMSGSIZE)
+			continue;
+
 		if (ret)
 			return ret;
 
diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c b/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c
index 41271301215a..aab17c4aaca8 100644
--- a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c
+++ b/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c
@@ -122,8 +122,8 @@ int quicki2c_get_report_descriptor(struct quicki2c_device *qcdev)
 	size_t read_len = le16_to_cpu(qcdev->dev_desc.report_desc_len);
 	u32 prd_len = read_len;
 
-	return thc_swdma_read(qcdev->thc_hw, (u8 *)&desc_reg, HIDI2C_REG_LEN,
-			      &prd_len, qcdev->report_descriptor, &read_len);
+	return thc_swdma_read_safe(qcdev->thc_hw, (u8 *)&desc_reg, HIDI2C_REG_LEN,
+				   &prd_len, qcdev->report_descriptor, read_len, &read_len);
 }
 
 int quicki2c_get_report(struct quicki2c_device *qcdev, u8 report_type,
@@ -153,7 +153,8 @@ int quicki2c_get_report(struct quicki2c_device *qcdev, u8 report_type,
 
 	rpt = (struct hidi2c_report_packet *)qcdev->input_buf;
 
-	ret = thc_swdma_read(qcdev->thc_hw, qcdev->report_buf, len, NULL, rpt, &read_len);
+	ret = thc_swdma_read_safe(qcdev->thc_hw, qcdev->report_buf, len, NULL, rpt,
+				  HIDI2C_PACKET_LEN(qcdev->input_len), &read_len);
 	if (ret) {
 		dev_err_once(qcdev->dev, "Get report failed, ret %d, read len (%zu vs %zu)\n",
 			     ret, read_len, buf_len);
-- 
2.43.0


  parent reply	other threads:[~2026-11-16  8:27 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 ` Even Xu [this message]
2026-11-16  8:28 ` [PATCH 4/4] HID: Intel-thc-hid: Intel-thc: Restore RXDMA after SWDMA operation errors Even Xu

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-4-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

all inboxes | Powered by JetHome®