* [PATCH 0/4] Fix potential THC DMA issues
@ 2026-11-16 8:27 Even Xu
2026-11-16 8:27 ` [PATCH 1/4] HID: Intel-thc-hid: Intel-thc: Add safe DMA read interfaces Even Xu
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Even Xu @ 2026-11-16 8:27 UTC (permalink / raw)
To: bentiss, jikos; +Cc: srinivas.pandruvada, linux-input, linux-kernel, Even Xu
This patch set fix two potential THC DMA issues:
1. THC DMA buffers are rounded up to a 4 KB boundary, but callers may
allocate smaller receive buffers. Checking a frame against the DMA
capacity alone does not protect the destination when do DMA buffer
copying.
2. 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.
The fixes are:
1. Add thc_rxdma_read_safe() and thc_swdma_read_safe() with an explicit
destination capacity to check both the DMA capacity and the supplied
size before copying.
2. Call thc_swdma_read_completion() even when reading the completed
response fails, so RXDMA and the saved I2C controls can be restored.
Even Xu (4):
HID: Intel-thc-hid: Intel-thc: Add safe DMA read interfaces
HID: Intel-thc-hid: Intel-quickspi: Use safe RXDMA reads
HID: Intel-thc-hid: Intel-quicki2c: Use safe DMA reads
HID: Intel-thc-hid: Intel-thc: Restore RXDMA after SWDMA operation
errors
.../intel-quicki2c/pci-quicki2c.c | 9 +-
.../intel-quicki2c/quicki2c-protocol.c | 7 +-
.../intel-quickspi/pci-quickspi.c | 12 +-
.../intel-quickspi/quickspi-dev.h | 7 ++
.../intel-thc-hid/intel-thc/intel-thc-dma.c | 103 ++++++++++++++----
.../intel-thc-hid/intel-thc/intel-thc-dma.h | 6 +
6 files changed, 115 insertions(+), 29 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] HID: Intel-thc-hid: Intel-thc: Add safe DMA read interfaces
2026-11-16 8:27 [PATCH 0/4] Fix potential THC DMA issues Even Xu
@ 2026-11-16 8:27 ` Even Xu
2026-11-16 8:27 ` [PATCH 2/4] HID: Intel-thc-hid: Intel-quickspi: Use safe RXDMA reads Even Xu
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Even Xu @ 2026-11-16 8:27 UTC (permalink / raw)
To: bentiss, jikos
Cc: srinivas.pandruvada, linux-input, linux-kernel, Even Xu, Rui Zhang
THC DMA buffers are rounded up to a 4 KB boundary, but callers may
allocate smaller receive buffers. Checking a frame against the DMA
capacity alone does not protect the destination when do DMA buffer
copying.
Add thc_rxdma_read_safe() and thc_swdma_read_safe() with an explicit
destination capacity to check both the DMA capacity and the supplied
size before copying.
Keep the original interfaces as compatibility wrappers.
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>
---
.../intel-thc-hid/intel-thc/intel-thc-dma.c | 95 ++++++++++++++++---
.../intel-thc-hid/intel-thc/intel-thc-dma.h | 6 ++
2 files changed, 86 insertions(+), 15 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 c80ef8c20574..11d29c8daebe 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
@@ -614,7 +614,7 @@ EXPORT_SYMBOL_NS_GPL(thc_rxdma_reset, "INTEL_THC");
static int read_dma_buffer(struct thc_device *dev,
struct thc_dma_configuration *read_config,
- u8 prd_table_index, void *read_buff)
+ u8 prd_table_index, void *read_buff, size_t read_buff_len)
{
struct thc_prd_table *prd_tbl;
struct scatterlist *sg;
@@ -640,6 +640,13 @@ static int read_dma_buffer(struct thc_device *dev,
return -EMSGSIZE;
}
+ if (mes_len > read_buff_len) {
+ dev_err(dev->dev,
+ "Message length %zu is bigger than destination buffer length %zu\n",
+ mes_len, read_buff_len);
+ return -EMSGSIZE;
+ }
+
sg = read_config->sgls[prd_table_index];
ret = sg_copy_to_buffer(sg, nent, read_buff, mes_len);
if (ret != mes_len) {
@@ -680,21 +687,26 @@ static int is_dma_buf_empty(struct thc_device *dev,
static int thc_dma_read(struct thc_device *dev,
struct thc_dma_configuration *read_config,
- void *read_buff, size_t *read_len, int *read_finished)
+ void *read_buff, size_t read_buff_len,
+ size_t *read_len, int *read_finished)
{
u8 read_ptr, write_ptr, prd_table_index;
- int status;
+ int status = 0;
+
+ *read_len = 0;
if (!is_dma_buf_empty(dev, read_config, &read_ptr, &write_ptr)) {
prd_table_index = write_ptr & THC_POINTER_MASK;
- status = read_dma_buffer(dev, read_config, prd_table_index, read_buff);
- if (status <= 0) {
+ status = read_dma_buffer(dev, read_config, prd_table_index,
+ read_buff, read_buff_len);
+ if (status <= 0 && status != -EMSGSIZE) {
dev_err_once(dev->dev, "read DMA buffer failed %d\n", status);
return -EIO;
}
- *read_len = status;
+ if (status > 0)
+ *read_len = status;
/* Clear the relevant PRD table */
thc_copy_one_sgl_to_prd(dev, read_config, prd_table_index);
@@ -711,22 +723,27 @@ static int thc_dma_read(struct thc_device *dev,
if (read_finished)
*read_finished = is_dma_buf_empty(dev, read_config, &read_ptr, &write_ptr) ? 1 : 0;
- return 0;
+ return status < 0 ? status : 0;
}
/**
- * thc_rxdma_read - Read data from RXDMA buffer
+ * thc_rxdma_read_safe - Read data from RXDMA buffer with a destination size limit
*
* @dev: The pointer of THC private device context
* @dma_channel: The RXDMA engine of read data source
* @read_buff: The pointer of the read data buffer
+ * @read_buff_len: The allocated size of the read data buffer in bytes
* @read_len: The pointer of the read data length
* @read_finished: The pointer of the flag indicating if all pending data has been read out
*
+ * Oversized frames are discarded and their PRD table is recycled without
+ * copying data. In this case, @read_len is zero and @read_finished is updated.
+ *
* Return: 0 on success, other error codes on failed.
*/
-int thc_rxdma_read(struct thc_device *dev, enum thc_dma_channel dma_channel,
- void *read_buff, size_t *read_len, int *read_finished)
+int thc_rxdma_read_safe(struct thc_device *dev, enum thc_dma_channel dma_channel,
+ void *read_buff, size_t read_buff_len,
+ size_t *read_len, int *read_finished)
{
struct thc_dma_configuration *dma_config;
int ret;
@@ -749,10 +766,31 @@ int thc_rxdma_read(struct thc_device *dev, enum thc_dma_channel dma_channel,
return -EINVAL;
}
- ret = thc_dma_read(dev, dma_config, read_buff, read_len, read_finished);
+ ret = thc_dma_read(dev, dma_config, read_buff, read_buff_len, read_len, read_finished);
return ret;
}
+EXPORT_SYMBOL_NS_GPL(thc_rxdma_read_safe, "INTEL_THC");
+
+/**
+ * thc_rxdma_read - Read data from RXDMA buffer
+ *
+ * @dev: The pointer of THC private device context
+ * @dma_channel: The RXDMA engine of read data source
+ * @read_buff: The pointer of the read data buffer
+ * @read_len: The pointer of the read data length
+ * @read_finished: The pointer of the flag indicating if all pending data has been read out
+ *
+ * Legacy callers do not provide a destination capacity.
+ *
+ * Return: 0 on success, other error codes on failed.
+ */
+int thc_rxdma_read(struct thc_device *dev, enum thc_dma_channel dma_channel,
+ void *read_buff, size_t *read_len, int *read_finished)
+{
+ return thc_rxdma_read_safe(dev, dma_channel, read_buff, SIZE_MAX,
+ read_len, read_finished);
+}
EXPORT_SYMBOL_NS_GPL(thc_rxdma_read, "INTEL_THC");
static int thc_swdma_read_start(struct thc_device *dev, void *write_buff,
@@ -862,19 +900,23 @@ static int thc_swdma_read_completion(struct thc_device *dev)
}
/**
- * thc_swdma_read - Use software DMA to read data from touch device
+ * thc_swdma_read_safe - Read touch device data with a destination size limit
*
* @dev: The pointer of THC private device context
* @write_buff: The pointer of write buffer for SWDMA sequence
* @write_len: The write data length for SWDMA sequence
* @prd_tbl_len: The prd table length of SWDMA engine, can be set to NULL
* @read_buff: The pointer of the read data buffer
+ * @read_buff_len: The allocated size of the read data buffer in bytes
* @read_len: The pointer of the read data length
*
+ * Oversized frames are discarded without copying data and @read_len is zero.
+ *
* Return: 0 on success, other error codes on failed.
*/
-int thc_swdma_read(struct thc_device *dev, void *write_buff, size_t write_len,
- u32 *prd_tbl_len, void *read_buff, size_t *read_len)
+int thc_swdma_read_safe(struct thc_device *dev, void *write_buff, size_t write_len,
+ u32 *prd_tbl_len, void *read_buff, size_t read_buff_len,
+ size_t *read_len)
{
int ret;
@@ -905,7 +947,8 @@ int thc_swdma_read(struct thc_device *dev, void *write_buff, size_t write_len,
goto end;
}
- ret = thc_dma_read(dev, &dev->dma_ctx->dma_config[THC_SWDMA], read_buff, read_len, NULL);
+ ret = thc_dma_read(dev, &dev->dma_ctx->dma_config[THC_SWDMA],
+ read_buff, read_buff_len, read_len, NULL);
if (ret)
goto end;
@@ -915,6 +958,28 @@ int thc_swdma_read(struct thc_device *dev, void *write_buff, size_t write_len,
mutex_unlock(&dev->thc_bus_lock);
return ret;
}
+EXPORT_SYMBOL_NS_GPL(thc_swdma_read_safe, "INTEL_THC");
+
+/**
+ * thc_swdma_read - Use software DMA to read data from touch device
+ *
+ * @dev: The pointer of THC private device context
+ * @write_buff: The pointer of write buffer for SWDMA sequence
+ * @write_len: The write data length for SWDMA sequence
+ * @prd_tbl_len: The prd table length of SWDMA engine, can be set to NULL
+ * @read_buff: The pointer of the read data buffer
+ * @read_len: The pointer of the read data length
+ *
+ * Legacy callers do not provide a destination capacity.
+ *
+ * Return: 0 on success, other error codes on failed.
+ */
+int thc_swdma_read(struct thc_device *dev, void *write_buff, size_t write_len,
+ u32 *prd_tbl_len, void *read_buff, size_t *read_len)
+{
+ return thc_swdma_read_safe(dev, write_buff, write_len, prd_tbl_len,
+ read_buff, SIZE_MAX, read_len);
+}
EXPORT_SYMBOL_NS_GPL(thc_swdma_read, "INTEL_THC");
static int write_dma_buffer(struct thc_device *dev,
diff --git a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.h b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.h
index 715423453a9d..f6152b4209f7 100644
--- a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.h
+++ b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.h
@@ -150,6 +150,12 @@ int thc_rxdma_read(struct thc_device *dev, enum thc_dma_channel dma_channel,
void *read_buff, size_t *read_len, int *read_finished);
int thc_swdma_read(struct thc_device *dev, void *write_buff, size_t write_len,
u32 *prd_tbl_len, void *read_buff, size_t *read_len);
+int thc_rxdma_read_safe(struct thc_device *dev, enum thc_dma_channel dma_channel,
+ void *read_buff, size_t read_buff_len,
+ size_t *read_len, int *read_finished);
+int thc_swdma_read_safe(struct thc_device *dev, void *write_buff, size_t write_len,
+ u32 *prd_tbl_len, void *read_buff, size_t read_buff_len,
+ size_t *read_len);
int thc_dma_write(struct thc_device *dev, void *buffer, size_t buf_len);
struct thc_dma_context *thc_dma_init(struct thc_device *dev);
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/4] HID: Intel-thc-hid: Intel-quickspi: Use safe RXDMA reads
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 ` 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 ` [PATCH 4/4] HID: Intel-thc-hid: Intel-thc: Restore RXDMA after SWDMA operation errors Even Xu
3 siblings, 0 replies; 5+ messages in thread
From: Even Xu @ 2026-11-16 8:27 UTC (permalink / raw)
To: bentiss, jikos
Cc: srinivas.pandruvada, linux-input, linux-kernel, Even Xu, Rui Zhang
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 3041 bytes --]
Use thc_rxdma_read_safe() and pass the full input_buf allocation,
including the body header. Handle -EMSGSIZE in the receive loop by
skipping the discarded frame and continuing pending reports instead
of scheduling a full RXDMA recovery.
Fixes: 4138f21115ae ("HID: intel-thc-hid: intel-quickspi: Complete THC QuickSPI driver")
Signed-off-by: Even Xu <even.xu@intel.com>
Tested-by: Rui Zhang <rui1.zhang@intel.com>
---
.../hid/intel-thc-hid/intel-quickspi/pci-quickspi.c | 12 ++++++++----
.../hid/intel-thc-hid/intel-quickspi/quickspi-dev.h | 7 +++++++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c b/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
index ec974d549a92..703ba238c02a 100644
--- a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
+++ b/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
@@ -324,8 +324,12 @@ static irqreturn_t quickspi_irq_thread_handler(int irq, void *dev_id)
if (int_mask & BIT(THC_RXDMA2_INT)) {
while (!read_finished) {
- ret = thc_rxdma_read(qsdev->thc_hw, THC_RXDMA2, qsdev->input_buf,
- &input_len, &read_finished);
+ ret = thc_rxdma_read_safe(qsdev->thc_hw, THC_RXDMA2, qsdev->input_buf,
+ HIDSPI_INPUT_BODY_SIZE(qsdev->input_len),
+ &input_len, &read_finished);
+ if (ret == -EMSGSIZE)
+ continue;
+
if (ret) {
err_recover = 1;
goto end;
@@ -550,7 +554,7 @@ static int quickspi_alloc_report_buf(struct quickspi_device *qsdev)
return -ENOMEM;
max_input_len = max(le16_to_cpu(qsdev->dev_desc.rep_desc_len),
- le16_to_cpu(qsdev->dev_desc.max_input_len));
+ le16_to_cpu(qsdev->dev_desc.max_input_len)) + QUICKSPI_DMA_EXTRA_BYTE;
qsdev->input_buf = devm_kzalloc(qsdev->dev,
HIDSPI_INPUT_BODY_SIZE(max_input_len), GFP_KERNEL);
@@ -560,7 +564,7 @@ static int quickspi_alloc_report_buf(struct quickspi_device *qsdev)
qsdev->input_len = max_input_len;
max_report_len = max(le16_to_cpu(qsdev->dev_desc.max_output_len),
- le16_to_cpu(qsdev->dev_desc.max_input_len));
+ le16_to_cpu(qsdev->dev_desc.max_input_len)) + QUICKSPI_DMA_EXTRA_BYTE;
qsdev->report_buf = devm_kzalloc(qsdev->dev,
HIDSPI_OUTPUT_REPORT_SIZE(max_report_len), GFP_KERNEL);
diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h
index 4362ac568bda..e8ddb504ccc7 100644
--- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h
+++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h
@@ -54,6 +54,13 @@
#define MAX_PACKET_SIZE_VALUE_MTL 128
#define MAX_PACKET_SIZE_VALUE_LNL 256
+/*
+ * During HID-over-SPI transfers, THC DMA may also read bytes that aren’t
+ * part of the actual data, such as a placeholder byte used for timing
+ * control (8 clock cycles).
+ */
+#define QUICKSPI_DMA_EXTRA_BYTE 1
+
/*
* THC uses runtime auto suspend to dynamically switch between THC active LTR
* and low power LTR to save CPU power.
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/4] HID: Intel-thc-hid: Intel-quicki2c: Use safe DMA reads
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
2026-11-16 8:28 ` [PATCH 4/4] HID: Intel-thc-hid: Intel-thc: Restore RXDMA after SWDMA operation errors Even Xu
3 siblings, 0 replies; 5+ messages in thread
From: Even Xu @ 2026-11-16 8:27 UTC (permalink / raw)
To: bentiss, jikos
Cc: srinivas.pandruvada, linux-input, linux-kernel, Even Xu, Rui Zhang
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 4/4] HID: Intel-thc-hid: Intel-thc: Restore RXDMA after SWDMA operation errors
2026-11-16 8:27 [PATCH 0/4] Fix potential THC DMA issues Even Xu
` (2 preceding siblings ...)
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
3 siblings, 0 replies; 5+ messages in thread
From: Even Xu @ 2026-11-16 8:28 UTC (permalink / raw)
To: bentiss, jikos
Cc: srinivas.pandruvada, linux-input, linux-kernel, Even Xu, Rui Zhang
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-16 8:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 4/4] HID: Intel-thc-hid: Intel-thc: Restore RXDMA after SWDMA operation errors Even Xu
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®