HID: intel-thc-hid: quiesce interrupts before final teardown
Subsystems (2)
cover HID: intel-thc-hid: quiesce interrupts before final teardown
QuickSPI and QuickI2C can tear down HID/DMA resources while IRQ handlers are still running. Stop new IRQ handling, wait for running handlers, then drain recovery work and mask THC interrupts before final teardown.
This series covers remove, probe unwind and shutdown.
GCC 15.2.0 x86_64 W=1 builds, strict checkpatch and patch application checks passed. No hardware runtime testing.
Base: 238650ef6c7c7cca08e032527329424c9fbd70e5
1. HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
2. HID: intel-thc-hid: quicki2c: quiesce IRQs during teardown
PATCH 1/2 HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
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 static analysis.
---
Compile-tested with GCC, W=1 (x86_64). No runtime testing.
Related recovery-work review and series:
https://lore-kernel.gnuweeb.org/linux-input/[email protected]/T/
https://patchew.org/linux/[email protected]/
.../intel-quickspi/pci-quickspi.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +22 -6
@@ -597,6 +597,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;
@@ -649,6 +651,7 @@ static int quickspi_probe(struct pci_dev *pdev, qsdev);if (ret) goto dev_deinit; + irq_requested = true; ret =reset_tic (qsdev);if (ret) {
@@ -667,17 +670,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 ;
@@ -692,10 +696,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);
@@ -718,9 +728,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);
@@ -747,6 +760,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 */
PATCH 2/2 HID: intel-thc-hid: quicki2c: quiesce IRQs during teardown
In reply to Myeonghun PakThe 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 static analysis.
---
Compile-tested with GCC, W=1 (x86_64). No runtime testing.
Related recovery-work review and series:
https://lore-kernel.gnuweeb.org/linux-input/[email protected]/T/
https://patchew.org/linux/[email protected]/
.../intel-quicki2c/pci-quicki2c.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c +22 -6
@@ -648,6 +648,8 @@ static int quicki2c_probe(struct pci_dev *pdev, const struct pci_device_id *id) {const struct quicki2c_ddata *ddata = (const struct quicki2c_ddata *)id->driver_data;struct quicki2c_device *qcdev; +bool dma_initialized = false; +bool irq_requested = false;void __iomem *mem_addr;int ret;
@@ -700,6 +702,7 @@ static int quicki2c_probe(struct pci_dev *pdev, const struct pci_device_id *id) qcdev);if (ret) goto dev_deinit; + irq_requested = true; ret =quicki2c_get_device_descriptor (qcdev);if (ret) {
@@ -718,6 +721,7 @@ static int quicki2c_probe(struct pci_dev *pdev, const struct pci_device_id *id)dev_err (&pdev->dev,"Setup THC DMA failed, ret= %d\n" , ret); goto dev_deinit; } + dma_initialized = true; ret =thc_interrupt_quiesce (qcdev->thc_hw, false);if (ret)
@@ -738,13 +742,13 @@ static int quicki2c_probe(struct pci_dev *pdev, const struct pci_device_id *id) ret =quicki2c_get_report_descriptor (qcdev);if (ret) {dev_err (&pdev->dev,"Get report descriptor failed, ret = %d\n" , ret); - goto dma_deinit; + goto dev_deinit; } ret =quicki2c_hid_probe (qcdev);if (ret) {dev_err (&pdev->dev,"Failed to register HID device, ret = %d\n" , ret); - goto dma_deinit; + goto dev_deinit; } qcdev->state =QUICKI2C_ENABLED ;
@@ -759,10 +763,16 @@ static int quicki2c_probe(struct pci_dev *pdev, const struct pci_device_id *id)return 0 ; -dma_deinit: -quicki2c_dma_deinit (qcdev); dev_deinit: +if (irq_requested) { +WRITE_ONCE (qcdev->recovery_disabled, true); +disable_irq (pdev->irq); + }quicki2c_dev_deinit (qcdev); +if (irq_requested) +devm_free_irq (&pdev->dev, pdev->irq, qcdev); +if (dma_initialized) +quicki2c_dma_deinit (qcdev); disable_pci_device:pci_clear_master (pdev);
@@ -784,9 +794,12 @@ static void quicki2c_remove(struct pci_dev *pdev)if (!qcdev)return ; -quicki2c_hid_remove (qcdev); - +WRITE_ONCE (qcdev->recovery_disabled, true); +disable_irq (pdev->irq);quicki2c_dev_deinit (qcdev); +devm_free_irq (&pdev->dev, pdev->irq, qcdev); + +quicki2c_hid_remove (qcdev);quicki2c_dma_deinit (qcdev);
@@ -811,6 +824,9 @@ static void quicki2c_shutdown(struct pci_dev *pdev)if (!qcdev)return ; +WRITE_ONCE (qcdev->recovery_disabled, true); +disable_irq (pdev->irq); +quicki2c_dev_deinit (qcdev);/* Must stop DMA before reboot to avoid DMA entering into unknown state */
[email protected]
AI reviewRe: [PATCH 2/2] HID: intel-thc-hid: quicki2c: quiesce IRQs during teardown
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] hid: intel-thc: 1s timeout on HID teardown commands due to early IRQ disable --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] hid: intel-thc: 1s timeout on HID teardown commands due to early IRQ disable --
commit 074bce22ab8075bef92df21dcd016a16b939a785
Author: Myeonghun Pak <[email protected]>
HID: intel-thc-hid: quicki2c: quiesce IRQs during teardown
This commit disables and synchronizes the IRQ, drains recovery work, and masks THC interrupts before freeing the IRQ and releasing HID/DMA resources. It tracks IRQ/DMA initialization for conditional probe cleanup and disables the IRQ during shutdown as well.
Quoted 4 lines
drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c +0
-0
[ ... ]
drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c static void quicki2c_remove(struct pci_dev *pdev) · line 806
Quoted 12 lines
drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c +5
-2@@ -788,9 +798,12 @@ static void quicki2c_remove(struct pci_dev *pdev)if (!qcdev)return ; -quicki2c_hid_remove (qcdev); - +WRITE_ONCE (qcdev->recovery_disabled, true); +disable_irq (pdev->irq);quicki2c_dev_deinit (qcdev); +devm_free_irq (&pdev->dev, pdev->irq, qcdev); + +quicki2c_hid_remove (qcdev);
[Severity: Medium]
Could moving the IRQ disable/free and device deinit before quicki2c_hid_remove() break any HID raw_requests issued during high-level driver teardown?
High-level HID drivers (like hid-multitouch) often send final commands (e.g., turning off LEDs or disabling features) during their remove callback, which is triggered by hid_destroy_device() inside quicki2c_hid_remove().
Since the patch moves disable_irq() and devm_free_irq() before quicki2c_hid_remove(), thc_dma_write() in intel-thc-dma.c will block for 1 second waiting for an IRQ completion that will never arrive:
ret = wait_event_interruptible_timeout(dev->write_complete_wait, dev->write_done, 1 * HZ);
if (ret <= 0 || !dev->write_done) {
dev_err_once(dev->dev, "timeout for waiting TxDMA completion\n");
ret = -ETIMEDOUT;
goto end;
}This might unconditionally introduce a 1-second delay per command during device unbind or system shutdown if the bound high-level HID driver issues any hardware commands in its remove callback.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
In reply to Myeonghun PakThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] hid: intel-thc-hid: DMA UAF due to HID deregistration race in remove --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hid: intel-thc-hid: DMA UAF due to HID deregistration race in remove --
commit 664b72e58bd5cb1485c8eb563326dab08180f916
Author: Myeonghun Pak <[email protected]>
HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
This commit disables and synchronizes the IRQ and drains recovery work prior to freeing the IRQ and releasing HID/DMA resources. It introduces this ordered teardown in both the probe error and remove paths.
Quoted 4 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +0
-0
[ ... ]
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c static void quickspi_remove(struct pci_dev *pdev) · line 739
Quoted 12 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +5
-2@@ -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);
[Severity: High]
Does this sequence open a race window for a hardware DMA use-after-free?
By tearing down the hardware and disabling interrupts before unregistering the HID device, it appears userspace can still issue a request via hidraw during unbind.
If a raw_request is queued on the disabled device, it may call thc_dma_write() to submit a TxDMA request:
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c:thc_dma_write() {
...
ret = wait_event_interruptible_timeout(dev->write_complete_wait, dev->write_done, 1 * HZ);
if (ret <= 0 || !dev->write_done) {
dev_err_once(dev->dev, "timeout for waiting TxDMA completion\n");
ret = -ETIMEDOUT;
goto end;
}
...
}Because IRQs are disabled here, the wait will time out and return -ETIMEDOUT, but it fails to clear the TxDMA START bit.
quickspi_remove() will then proceed to unregister the HID device and call quickspi_dma_deinit(), which frees the DMA buffers without clearing the TxDMA START bit. Could this allow the hardware TxDMA engine to remain active and access freed DMA memory, leading to memory corruption or an IOMMU fault?
Note that follow-up patches in the series do not appear to resolve this race.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Xu, Even
maintainerRE: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
In reply to Myeonghun PakQuoted 14 lines
-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: Monday, October 12, 2026 6:06 AM
To: Xu, Even <[email protected]>; Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>; Mark Pearson <[email protected]>; [email protected]; linux- [email protected]; Ijae Kim <[email protected]>
Subject: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownThe managed IRQ can access HID/DMA buffers or queue recovery work while remove or probe unwind tears down those resources.
Quoted 8 lines
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 static analysis.
Thanks for your patch!
I think this patch is still necessary. It can prevent some extremely unlikely but problematic cases, such as an interrupt already being queued in the thread before the THC interrupt is disabled. Have you tested this code on actual hardware?
Best Regards,
Even Xu
Quoted 108 lines
Fixes 4138f21115ae ("HID: intel-thc-hid: intel-quickspi: Complete THC QuickSPIdriver")
Assisted-by LLMCo-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>---
Compile-tested with GCC, W=1 (x86_64). No runtime testing.Related recovery-work review and series:
https://lore-kernel.gnuweeb.org/linux-input/20260717035609.3874015-1-
[email protected]/T/
https://patchew.org/linux/[email protected]/.../intel-quickspi/pci-quickspi.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +6
-2@@ -597,6 +597,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;@@ -649,6 +651,7 @@ static int quickspi_probe(struct pci_dev *pdev, qsdev);if (ret) goto dev_deinit; + irq_requested = true; ret =reset_tic (qsdev);if (ret) {@@ -667,17 +670,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; }drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +16
-4qsdev->state =QUICKSPI_ENABLED ;@@ -692,10 +696,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);@@ -718,9 +728,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);@@ -747,6 +760,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 */
Re: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
Hi Even,
Thanks for reviewing the patch.
No, I haven't tested it on actual hardware. I have only compile-tested it with GCC and W=1 on x86_64.
Best regards,
Myeonghun
2026년 10월 12일 (월) 오후 8:52, Xu, Even <[email protected]>님이 작성:
Quoted 139 lines
Quoted 15 lines
-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: Monday, October 12, 2026 6:06 AM
To: Xu, Even <[email protected]>; Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>; Mark Pearson <[email protected]>; [email protected]; linux- [email protected]; Ijae Kim <[email protected]>
Subject: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownThe managed IRQ can access HID/DMA buffers or queue recovery work while remove or probe unwind tears down those resources.
Quoted 8 lines
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 static analysis.
Thanks for your patch!
I think this patch is still necessary. It can prevent some extremely unlikely but problematic cases, such as an interrupt already being queued in the thread before the THC interrupt is disabled. Have you tested this code on actual hardware?
Best Regards,
Even XuQuoted 108 lines
Fixes 4138f21115ae ("HID: intel-thc-hid: intel-quickspi: Complete THC QuickSPIdriver")
Assisted-by LLMCo-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>---
Compile-tested with GCC, W=1 (x86_64). No runtime testing.Related recovery-work review and series:
https://lore-kernel.gnuweeb.org/linux-input/20260717035609.3874015-1-
[email protected]/T/
https://patchew.org/linux/[email protected]/.../intel-quickspi/pci-quickspi.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +6
-2@@ -597,6 +597,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;@@ -649,6 +651,7 @@ static int quickspi_probe(struct pci_dev *pdev, qsdev);if (ret) goto dev_deinit; + irq_requested = true; ret =reset_tic (qsdev);if (ret) {@@ -667,17 +670,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;drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +16
-4@@ -692,10 +696,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);@@ -718,9 +728,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);@@ -747,6 +760,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 */
Xu, Even
maintainerRE: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
Hi, Myeonghun,
Then let me test it, it may take several days.
Will feedback once test finished.
Best Regards,
Even Xu
Quoted 168 lines
-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: Thursday, October 15, 2026 8:36 AM
To: Xu, Even <[email protected]>
Cc: Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>; Srinivas Pandruvada <[email protected]>; Mark Pearson <mpearson- [email protected]>; [email protected]; [email protected]; Ijae Kim <[email protected]>
Subject: Re: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownHi Even,
Thanks for reviewing the patch.
No, I haven't tested it on actual hardware. I have only compile-tested it with GCC and W=1 on
x86_64.Best regards,
Myeonghun2026년 10월 12일 (월) 오후 8:52, Xu, Even <[email protected]>님이 작성:
Quoted 21 lines
Quoted 21 lines
-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: Monday, October 12, 2026 6:06 AM
To: Xu, Even <[email protected]>; Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>; Mark Pearson <[email protected]>; [email protected]; linux- [email protected]; Ijae Kim <[email protected]>
Subject: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownThe 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.
Quoted 8 lines
Quoted 4 lines
Disable the IRQ before shutdown deinit as well. Keep IRQ disabling and release outside the shared hibernation helper.
This issue was found by static analysis.
Thanks for your patch!
I think this patch is still necessary. It can prevent some extremely unlikely but
problematic cases, such as an interrupt already being queued in the thread before the THC interrupt is disabled. Have you tested this code on actual hardware?
Quoted 114 lines
Best Regards,
Even XuQuoted 110 lines
Fixes 4138f21115ae ("HID: intel-thc-hid: intel-quickspi: CompleteTHC QuickSPI
driver")Assisted-by LLMCo-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>---
Compile-tested with GCC, W=1 (x86_64). No runtime testing.Related recovery-work review and series:
https://lore-kernel.gnuweeb.org/linux-input/20260717035609.3874015-1
-
[email protected]/T/
https://patchew.org/linux/[email protected]
/.../intel-quickspi/pci-quickspi.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +6
-2@@ -597,6 +597,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;@@ -649,6 +651,7 @@ static int quickspi_probe(struct pci_dev *pdev, qsdev);if (ret) goto dev_deinit; + irq_requested = true; ret =reset_tic (qsdev);if (ret) {@@ -667,17 +670,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; @@ -692,10 +696,16 @@ staticint quickspi_probe(struct
pci_dev*pdev,return 0;drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +16
-4-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);@@ -718,9 +728,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);@@ -747,6 +760,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 */
Xu, Even
maintainerRE: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
Hi, Myeonghun,
Validation passed, but I suppose you need rebase your patches on top of latest mainline kernel.
Best Regards,
Even Xu
Quoted 195 lines
-----Original Message-----
From: Xu, Even
Sent: Thursday, October 15, 2026 9:53 AM
To: 'Myeonghun Pak' <[email protected]>
Cc: Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>; Srinivas Pandruvada <[email protected]>; Mark Pearson <mpearson- [email protected]>; [email protected]; [email protected]; Ijae Kim <[email protected]>
Subject: RE: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownHi, Myeonghun,
Then let me test it, it may take several days.
Will feedback once test finished.Best Regards,
Even XuQuoted 48 lines
-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: Thursday, October 15, 2026 8:36 AM
To: Xu, Even <[email protected]>
Cc: Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>; Srinivas Pandruvada <[email protected]>; Mark Pearson <mpearson- [email protected]>; [email protected]; [email protected]; Ijae Kim <[email protected]>
Subject: Re: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownHi Even,
Thanks for reviewing the patch.
No, I haven't tested it on actual hardware. I have only compile-tested it with GCC and W=1 on
x86_64.Best regards,
Myeonghun2026년 10월 12일 (월) 오후 8:52, Xu, Even <[email protected]>님이 작성:
Quoted 25 lines
Quoted 25 lines
-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: Monday, October 12, 2026 6:06 AM
To: Xu, Even <[email protected]>; Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>; Mark Pearson <[email protected]>; [email protected];
linux- [email protected]; Ijae Kim <[email protected]>
Subject: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownThe 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.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
This issue was found by static analysis.
Thanks for your patch!
I think this patch is still necessary. It can prevent some extremely unlikely but
problematic cases, such as an interrupt already being queued in the thread before the THC interrupt is disabled. Have you tested this code on actual
hardware?
Quoted 104 lines
Quoted 104 lines
Best Regards,
Even XuQuoted 100 lines
Fixes 4138f21115ae ("HID: intel-thc-hid: intel-quickspi: CompleteTHC QuickSPI
driver")Assisted-by LLMCo-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>---
Compile-tested with GCC, W=1 (x86_64). No runtime testing.Related recovery-work review and series:
https://lore-kernel.gnuweeb.org/linux-input/20260717035609.3874015
-1
-
[email protected]/T/
https://patchew.org/linux/[email protected]
om
/.../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.cb/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.cindex89226f5ce45e..0bd22f285c78100644drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +6
-2@@ -597,6 +597,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;@@ -649,6 +651,7 @@ static int quickspi_probe(struct pci_dev *pdev, qsdev);if (ret) goto dev_deinit; + irq_requested = true; ret =reset_tic (qsdev);if (ret) {@@ -667,17 +670,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; @@ -692,10 +696,16 @@static int quickspi_probe(struct
pci_dev*pdev,return 0;drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +13
-4-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);@@ -718,9 +728,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);Quoted 3 lines
Quoted 3 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c static void quickspi_shutdown(struct pci_dev
Quoted 3 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +0
-0quickspi_dma_deinit (qsdev);@@ -747,6 +760,9 @@ static void quickspi_shutdown(struct pci_dev*pdev)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +3
-0if (!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 */
Re: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
Hi Even,
Thanks for testing. I've rebased both patches onto the latest mainline with no other code changes.
Best regards,
Myeonghun
2026년 10월 26일 (월) 오후 10:05, Xu, Even <[email protected]>님이 작성:
Quoted 203 lines
Hi, Myeonghun,
Validation passed, but I suppose you need rebase your patches on top of latest mainline kernel.
Best Regards,
Even XuQuoted 195 lines
-----Original Message-----
From: Xu, Even
Sent: Thursday, October 15, 2026 9:53 AM
To: 'Myeonghun Pak' <[email protected]>
Cc: Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>; Srinivas Pandruvada <[email protected]>; Mark Pearson <mpearson- [email protected]>; [email protected]; [email protected]; Ijae Kim <[email protected]>
Subject: RE: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownHi, Myeonghun,
Then let me test it, it may take several days.
Will feedback once test finished.Best Regards,
Even XuQuoted 48 lines
-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: Thursday, October 15, 2026 8:36 AM
To: Xu, Even <[email protected]>
Cc: Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>; Srinivas Pandruvada <[email protected]>; Mark Pearson <mpearson- [email protected]>; [email protected]; [email protected]; Ijae Kim <[email protected]>
Subject: Re: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownHi Even,
Thanks for reviewing the patch.
No, I haven't tested it on actual hardware. I have only compile-tested it with GCC and W=1 on
x86_64.Best regards,
Myeonghun2026년 10월 12일 (월) 오후 8:52, Xu, Even <[email protected]>님이 작성:
Quoted 25 lines
Quoted 25 lines
-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: Monday, October 12, 2026 6:06 AM
To: Xu, Even <[email protected]>; Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>; Mark Pearson <[email protected]>; [email protected];
linux- [email protected]; Ijae Kim <[email protected]>
Subject: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownThe 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.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
This issue was found by static analysis.
Thanks for your patch!
I think this patch is still necessary. It can prevent some extremely unlikely but
problematic cases, such as an interrupt already being queued in the thread before the THC interrupt is disabled. Have you tested this code on actual
hardware?
Quoted 104 lines
Quoted 104 lines
Best Regards,
Even XuQuoted 100 lines
Fixes 4138f21115ae ("HID: intel-thc-hid: intel-quickspi: CompleteTHC QuickSPI
driver")Assisted-by LLMCo-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>---
Compile-tested with GCC, W=1 (x86_64). No runtime testing.Related recovery-work review and series:
https://lore-kernel.gnuweeb.org/linux-input/20260717035609.3874015
-1
-
[email protected]/T/
https://patchew.org/linux/[email protected]
om
/.../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.cb/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.cindex89226f5ce45e..0bd22f285c78100644drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +6
-2@@ -597,6 +597,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;@@ -649,6 +651,7 @@ static int quickspi_probe(struct pci_dev *pdev, qsdev);if (ret) goto dev_deinit; + irq_requested = true; ret =reset_tic (qsdev);if (ret) {@@ -667,17 +670,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; @@ -692,10 +696,16 @@static int quickspi_probe(struct
pci_dev*pdev,return 0;drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +13
-4-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);@@ -718,9 +728,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);Quoted 3 lines
Quoted 3 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c static void quickspi_shutdown(struct pci_dev
Quoted 3 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +0
-0quickspi_dma_deinit (qsdev);@@ -747,6 +760,9 @@ static void quickspi_shutdown(struct pci_dev*pdev)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +3
-0if (!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 */
Xu, Even
maintainerRE: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
Hi, Myeonghun,
Got it, will review your new patches and feedback!
Best Regards,
Even Xu
Quoted 234 lines
-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: Tuesday, November 10, 2026 12:43 PM
To: Xu, Even <[email protected]>
Cc: Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>; Srinivas Pandruvada <[email protected]>; Mark Pearson <mpearson- [email protected]>; [email protected]; [email protected]; Ijae Kim <[email protected]>
Subject: Re: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownHi Even,
Thanks for testing. I've rebased both patches onto the latest mainline with no other code changes.
Best regards,
Myeonghun2026년 10월 26일 (월) 오후 10:05, Xu, Even <[email protected]>님이 작성:
Quoted 4 lines
Hi, Myeonghun,
Validation passed, but I suppose you need rebase your patches on top of latest
mainline kernel.
Quoted 48 lines
Best Regards,
Even XuQuoted 44 lines
-----Original Message-----
From: Xu, Even
Sent: Thursday, October 15, 2026 9:53 AM
To: 'Myeonghun Pak' <[email protected]>
Cc: Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>; Srinivas Pandruvada <[email protected]>; Mark Pearson <mpearson- [email protected]>; [email protected]; [email protected]; Ijae Kim <[email protected]>
Subject: RE: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownHi, Myeonghun,
Then let me test it, it may take several days.
Will feedback once test finished.Best Regards,
Even XuQuoted 24 lines
-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: Thursday, October 15, 2026 8:36 AM
To: Xu, Even <[email protected]>
Cc: Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>; Srinivas Pandruvada <[email protected]>; Mark Pearson
<mpearson- [email protected]>; [email protected]; [email protected]; Ijae Kim <[email protected]>
Subject: Re: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownHi Even,
Thanks for reviewing the patch.
No, I haven't tested it on actual hardware. I have only compile-tested it with GCC and W=1 on
x86_64.Best regards,
Myeonghun2026년 10월 12일 (월) 오후 8:52, Xu, Even <[email protected]>님이
작성:
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: Monday, October 12, 2026 6:06 AM
To: Xu, Even <[email protected]>; Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>; Mark Pearson <[email protected]>; [email protected];
linux- [email protected]; Ijae Kim <[email protected]>
Subject: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardownQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
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.
Quoted 64 lines
Quoted 64 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
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 static analysis.
Quoted 7 lines
Quoted 4 lines
Thanks for your patch!
I think this patch is still necessary. It can prevent some extremely unlikely but
problematic cases, such as an interrupt already being queued in the thread before the THC interrupt is disabled. Have you tested this code on actual
hardware?
Quoted 49 lines
Quoted 49 lines
Best Regards,
Even XuQuoted 45 lines
Fixes 4138f21115ae ("HID: intel-thc-hid: intel-quickspi:Complete THC QuickSPI
driver")Assisted-by LLMCo-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>---
Compile-tested with GCC, W=1 (x86_64). No runtime testing.Related recovery-work review and series:
https://lore-kernel.gnuweeb.org/linux-input/20260717035609.387
4015
-1
-
[email protected]/T/
https://patchew.org/linux/20260729050145.2272597-1-even.xu@intel.c
om
/.../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.cb/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.cindex89226f5ce45e..0bd22f285c78100644drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +3
-0@@ -597,6 +597,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;@@ -649,6 +651,7 @@ static int quickspi_probe(struct pci_dev *pdev, qsdev);if (ret) goto dev_deinit; + irq_requested = true;Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c static int quickspi_probe(struct pci_dev
Quoted 3 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +0
-0ret =reset_tic (qsdev);if (ret) {@@ -667,17 +670,18 @@ static int quickspi_probe(struct pci_dev*pdev,
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +3
-2dev_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; @@ -692,10 +696,16 @@static int quickspi_probe(struct
pci_dev*pdev,return 0;drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +8
-2-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);Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c static void quickspi_remove(struct pci_dev
Quoted 1 line
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +0
-0@@ -718,9 +728,12 @@ static void quickspi_remove(struct pci_dev*pdev)
Quoted 27 lines
Quoted 27 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +5
-2if (!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);Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +0
-0quickspi_dma_deinit (qsdev);@@ -747,6 +760,9 @@ static void quickspi_shutdown(struct
pci_dev*pdev)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
if (!qsdev) return;drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +3
-0+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 */