From: Myeonghun Pak <mhun512@gmail.com>
To: Even Xu <even.xu@intel.com>, Xinpeng Sun <xinpeng.sun@intel.com>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>
Cc: Myeonghun Pak <mhun512@gmail.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Mark Pearson <mpearson-lenovo@squebb.ca>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Ijae Kim <ae878000@gmail.com>
Subject: [PATCH v2 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
Date: Mon, 9 Nov 2026 23:47:18 -0500 [thread overview]
Message-ID: <20261109-thc-rebase-v2-1-mhun512@gmail.com> (raw)
In-Reply-To: <20261109-thc-rebase-v2-0-mhun512@gmail.com>
The managed IRQ can access HID/DMA buffers or queue recovery work while
remove or probe unwind tears down those resources.
Disable and synchronize the IRQ, drain recovery work, then mask THC
interrupts before freeing the IRQ and releasing HID/DMA resources.
Track IRQ/DMA initialization for conditional probe cleanup.
Disable the IRQ before shutdown deinit as well. Keep IRQ disabling and
release outside the shared hibernation helper.
This issue was found by our static analysis tool under development.
Fixes: 4138f21115ae ("HID: intel-thc-hid: intel-quickspi: Complete THC QuickSPI driver")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
No hardware testing.
Changes in v2:
- Rebase on mainline b3dfbde62cf1. No source changes from v1.
.../intel-thc-hid/intel-quickspi/pci-quickspi.c | 28 +++++++++++++++++-----
1 file changed, 22 insertions(+), 6 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 bf49d8ce5f07bed092339e46c444538d78cffe26..acb4d2716ea7450d2852a900c3f0acc1d7570421 100644
--- a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
+++ b/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
@@ -600,6 +600,8 @@ static int quickspi_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
struct quickspi_device *qsdev;
+ bool dma_initialized = false;
+ bool irq_requested = false;
void __iomem *mem_addr;
int ret;
@@ -652,6 +654,7 @@ static int quickspi_probe(struct pci_dev *pdev,
qsdev);
if (ret)
goto dev_deinit;
+ irq_requested = true;
ret = reset_tic(qsdev);
if (ret) {
@@ -670,17 +673,18 @@ static int quickspi_probe(struct pci_dev *pdev,
dev_err(&pdev->dev, "Setup THC DMA failed, ret= %d\n", ret);
goto dev_deinit;
}
+ dma_initialized = true;
ret = quickspi_get_report_descriptor(qsdev);
if (ret) {
dev_err(&pdev->dev, "Get report descriptor failed, ret = %d\n", ret);
- goto dma_deinit;
+ goto dev_deinit;
}
ret = quickspi_hid_probe(qsdev);
if (ret) {
dev_err(&pdev->dev, "Failed to register HID device, ret = %d\n", ret);
- goto dma_deinit;
+ goto dev_deinit;
}
qsdev->state = QUICKSPI_ENABLED;
@@ -695,10 +699,16 @@ static int quickspi_probe(struct pci_dev *pdev,
return 0;
-dma_deinit:
- quickspi_dma_deinit(qsdev);
dev_deinit:
+ if (irq_requested) {
+ WRITE_ONCE(qsdev->recovery_disabled, true);
+ disable_irq(pdev->irq);
+ }
quickspi_dev_deinit(qsdev);
+ if (irq_requested)
+ devm_free_irq(&pdev->dev, pdev->irq, qsdev);
+ if (dma_initialized)
+ quickspi_dma_deinit(qsdev);
disable_pci_device:
pci_clear_master(pdev);
@@ -721,9 +731,12 @@ static void quickspi_remove(struct pci_dev *pdev)
if (!qsdev)
return;
- quickspi_hid_remove(qsdev);
-
+ WRITE_ONCE(qsdev->recovery_disabled, true);
+ disable_irq(pdev->irq);
quickspi_dev_deinit(qsdev);
+ devm_free_irq(&pdev->dev, pdev->irq, qsdev);
+
+ quickspi_hid_remove(qsdev);
quickspi_dma_deinit(qsdev);
@@ -750,6 +763,9 @@ static void quickspi_shutdown(struct pci_dev *pdev)
if (!qsdev)
return;
+ WRITE_ONCE(qsdev->recovery_disabled, true);
+ disable_irq(pdev->irq);
+
quickspi_dev_deinit(qsdev);
/* Must stop DMA before reboot to avoid DMA entering into unknown state */
base-commit: b3dfbde62cf1981c4638939c159dfd087b7a72e9
--
2.53.0
next prev parent reply other threads:[~2026-11-10 4:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 4:47 [PATCH v2 0/2] HID: intel-thc-hid: " Myeonghun Pak
2026-11-10 4:47 ` Myeonghun Pak [this message]
2026-11-10 4:47 ` [PATCH v2 2/2] HID: intel-thc-hid: quicki2c: " Myeonghun Pak
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=20261109-thc-rebase-v2-1-mhun512@gmail.com \
--to=mhun512@gmail.com \
--cc=ae878000@gmail.com \
--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=mpearson-lenovo@squebb.ca \
--cc=srinivas.pandruvada@linux.intel.com \
--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
all inboxes | Powered by JetHome®