From: Emfox Zhou <emfox@debian.org>
To: Even Xu <even.xu@intel.com>, Xinpeng Sun <xinpeng.sun@intel.com>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/5] HID: intel-thc-hid: intel-thc: keep TxDMA write errors
Date: Mon, 16 Nov 2026 21:31:28 +0800 [thread overview]
Message-ID: <20261116133132.1282020-2-emfox@debian.org> (raw)
In-Reply-To: <20261116133132.1282020-1-emfox@debian.org>
thc_dma_write() reports success after a timeout: the cleanup at the end
overwrites the error with the result of thc_interrupt_quiesce(), so a
frame that never left the device is taken as sent.
That wait also ends on a signal, and the no-completion branch folds the
result into -ETIMEDOUT. There is nothing to restart here: the frame is
already in the engine, so a restarted write() would hand the same report
to the controller twice. Wait without interruption, the window is one
second, and report a failing interrupt restore instead of dropping it.
The completion interrupt wakes the queue with wake_up_interruptible(),
whose mask does not intersect TASK_UNINTERRUPTIBLE: a completion that
arrives after the task sleeps is dropped, and the write waits out its
timer with the bus lock held. Wake all waiters instead.
Fixes: a688404b2e20 ("HID: intel-thc-hid: intel-thc: Add THC DMA interfaces")
Signed-off-by: Emfox Zhou <emfox@debian.org>
---
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c | 2 +-
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c | 9 +++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
index 7feda4160..7429f851c 100644
--- a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
+++ b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
@@ -990,7 +990,7 @@ int thc_interrupt_handler(struct thc_device *dev)
THC_M_PRT_WRITE_INT_STS_OFFSET, write_sts);
dev->write_done = true;
- wake_up_interruptible(&dev->write_complete_wait);
+ wake_up(&dev->write_complete_wait);
interrupt_type |= BIT(THC_TXDMA_INT);
}
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..c0dc44e26 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
@@ -1045,8 +1045,9 @@ int thc_dma_write(struct thc_device *dev, void *buffer, size_t buf_len)
dma_set_start_bit(dev, &dev->dma_ctx->dma_config[THC_TXDMA]);
- ret = wait_event_interruptible_timeout(dev->write_complete_wait, dev->write_done, 1 * HZ);
- if (ret <= 0 || !dev->write_done) {
+ ret = wait_event_timeout(dev->write_complete_wait,
+ dev->write_done, 1 * HZ);
+ if (!ret || !dev->write_done) {
dev_err_once(dev->dev, "timeout for waiting TxDMA completion\n");
ret = -ETIMEDOUT;
goto end;
@@ -1059,8 +1060,8 @@ int thc_dma_write(struct thc_device *dev, void *buffer, size_t buf_len)
end:
mutex_unlock(&dev->thc_bus_lock);
- if (restore_interrupts)
- ret = thc_interrupt_quiesce(dev, false);
+ if (restore_interrupts && thc_interrupt_quiesce(dev, false))
+ dev_err(dev->dev, "failed to restore interrupts after TxDMA write\n");
return ret;
}
next prev parent reply other threads:[~2026-11-16 13:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 13:31 [PATCH 0/5] HID: intel-thc-hid: intel-thc: DMA lifetime fixes Emfox Zhou
2026-11-16 13:31 ` Emfox Zhou [this message]
2026-11-16 13:49 ` [PATCH 1/5] HID: intel-thc-hid: intel-thc: keep TxDMA write errors sashiko-bot
2026-11-16 13:31 ` [PATCH 2/5] HID: intel-thc-hid: intel-thc: free the failed channel Emfox Zhou
2026-11-16 13:31 ` [PATCH 3/5] HID: intel-thc-hid: intel-thc: stop all engines first Emfox Zhou
2026-11-16 13:39 ` sashiko-bot
2026-11-16 13:31 ` [PATCH 4/5] HID: intel-thc-hid: intel-thc: add the slow SPI gears Emfox Zhou
2026-11-16 13:31 ` [PATCH 5/5] HID: intel-thc-hid: intel-thc: budget the receive drain Emfox Zhou
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=20261116133132.1282020-2-emfox@debian.org \
--to=emfox@debian.org \
--cc=bentiss@kernel.org \
--cc=even.xu@intel.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xinpeng.sun@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