[PATCH 3/4] HID: Intel-thc-hid: Intel-quicki2c: Use safe DMA reads
From: Even Xu
Date: Mon Nov 16 2026 - 03:27:49 EST
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@xxxxxxxxx>
Tested-by: Rui Zhang <rui1.zhang@xxxxxxxxx>
---
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