Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Emfox Zhou" <emfox@debian.org>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v3 4/5] HID: intel-thc-hid: intel-ipts: handle system sleep
Date: Sat, 14 Nov 2026 19:02:43 +0000	[thread overview]
Message-ID: <sashiko-outbox-214937@kernel.org> (raw)
In-Reply-To: <20261114183624.2379573-5-emfox@debian.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: intel-thc-hid: intel-ipts: race in thc_ipts_port_stop()
  re-enables IRQ
--

commit c33cb8e49648df90b4589c66ad8cc8769f40b6b6
Author: Emfox Zhou <emfox@debian.org>

HID: intel-thc-hid: intel-ipts: handle system sleep

This commit adds system sleep and resume callbacks to the intel-ipts PCI
driver by stopping and restarting the port across suspend and resume.

> diff --git a/drivers/hid/intel-thc-hid/intel-ipts/pci-ipts.c b/drivers/hid/intel-thc-hid/intel-ipts/pci-ipts.c
> index 8f8db21df8250..81a46149be2e9 100644
> --- a/drivers/hid/intel-thc-hid/intel-ipts/pci-ipts.c
> +++ b/drivers/hid/intel-thc-hid/intel-ipts/pci-ipts.c
> @@ -142,6 +142,41 @@ static void thc_ipts_remove(struct pci_dev *pci)
>  	pci_clear_master(pci);
>  }
>  
> +/*
> + * The controller forgets the streaming mode and hidraw cannot ask user space
> + * to repeat itself, so the port is taken down and rebuilt: the HID device
> + * comes back and the daemon restarts with it.
> + */
> +static int thc_ipts_suspend(struct device *dev)
> +{
> +	struct thc_ipts *idev = dev_get_drvdata(dev);
> +
> +	if (!idev)
> +		return -ENODEV;
> +
> +	thc_ipts_port_stop(idev);

[Severity: Medium]
Can thc_ipts_port_stop() race with thc_ipts_thread() or thc_ipts_recover()
and leave THC interrupts enabled across suspend and resume?

CPU0                                     CPU1
thc_ipts_suspend()
  thc_ipts_port_stop()
                                         thc_ipts_thread()
                                           if (!READ_ONCE(idev->stopping))
    WRITE_ONCE(idev->stopping, true);
    thc_interrupt_enable(idev->thc, false);
                                             thc_interrupt_enable(idev->thc, true);
    synchronize_irq(idev->irq);
    cancel_work_sync(&idev->recover_work);

thc_ipts_port_stop() masks interrupts before synchronize_irq() and
cancel_work_sync(), and does not mask them again after those calls finish.
If the IRQ remains registered across suspend and resume and the controller
raises an interrupt during thc_ipts_touch_set() or during
thc_ipts_resume() -> thc_ipts_port_start() before idev->dma_ready is set,
thc_ipts_hardirq() sees idev->stopping or !idev->dma_ready and returns
IRQ_NONE without clearing the hardware status bits:

drivers/hid/intel-thc-hid/intel-ipts/ipts.c:thc_ipts_hardirq() {
	struct thc_ipts *idev = data;

	if (READ_ONCE(idev->stopping) || !READ_ONCE(idev->dma_ready))
		return IRQ_NONE;
    ...
}

Calling thc_interrupt_enable(idev->thc, false) again after
synchronize_irq() and cancel_work_sync() in thc_ipts_port_stop() would
ensure interrupts stay masked once both contexts have exited.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261114183624.2379573-1-emfox@debian.org?part=4

  reply	other threads:[~2026-11-14 19:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 18:36 [PATCH v3 0/5] HID: intel-thc-hid: intel-ipts: support THC IPTS ports Emfox Zhou
2026-11-14 18:36 ` [PATCH v3 1/5] HID: intel-thc-hid: intel-ipts: bring up the port Emfox Zhou
2026-11-14 18:55   ` sashiko-bot
2026-11-14 18:36 ` [PATCH v3 2/5] HID: intel-thc-hid: intel-ipts: receive reports Emfox Zhou
2026-11-14 19:10   ` sashiko-bot
2026-11-14 18:36 ` [PATCH v3 3/5] HID: intel-thc-hid: intel-ipts: register the HID device Emfox Zhou
2026-11-14 18:59   ` sashiko-bot
2026-11-14 18:36 ` [PATCH v3 4/5] HID: intel-thc-hid: intel-ipts: handle system sleep Emfox Zhou
2026-11-14 19:02   ` sashiko-bot [this message]
2026-11-14 18:36 ` [PATCH v3 5/5] HID: intel-thc-hid: intel-ipts: document the IPTS mode 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=sashiko-outbox-214937@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=emfox@debian.org \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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