All of lore.kernel.org
 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 v8 2/5] HID: intel-thc-hid: intel-ipts: receive reports
Date: Wed, 18 Nov 2026 07:19:43 +0000	[thread overview]
Message-ID: <sashiko-outbox-220301@kernel.org> (raw)
In-Reply-To: <20261118065725.673090-3-emfox@debian.org>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] HID: intel-thc-hid: intel-ipts: invalid wait context in
  thc_ipts_hardirq()
- [Medium] HID: intel-ipts: thc_ipts_thread() claims foreign shared IRQs
  when recovering
--

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

HID: intel-thc-hid: intel-ipts: receive reports

This commit configures the receive and transmit DMA engines, requests the
port interrupt with error recovery, and decodes incoming frames.

> diff --git a/drivers/hid/intel-thc-hid/intel-ipts/ipts.c b/drivers/hid/intel-thc-hid/intel-ipts/ipts.c
> index 2d14e5278f986..e7896b16f1ada 100644
> --- a/drivers/hid/intel-thc-hid/intel-ipts/ipts.c
> +++ b/drivers/hid/intel-thc-hid/intel-ipts/ipts.c
[ ... ]
> @@ -129,6 +144,283 @@ static int thc_ipts_touch_set(struct thc_ipts *idev, bool enable)
[ ... ]
> +irqreturn_t thc_ipts_hardirq(int irq, void *data)
> +{
> +	struct thc_ipts *idev = data;
> +
> +	/* Nothing of ours is pending: the cause belongs to a sharer. */
> +	if (!READ_ONCE(idev->dma_ready))
> +		return IRQ_NONE;
> +
> +	/* Level triggered and shared: mask first, or it stays asserted. */
> +	thc_interrupt_enable(idev->thc, false);
> +
> +	/*
> +	 * A reset or a teardown in flight still gets the thread: the status it
> +	 * drains is where a pending transmit completion is delivered, and a
> +	 * write waiting for that one holds the bus lock the reset needs.
> +	 */
> +	return IRQ_WAKE_THREAD;
> +}

[Severity: Medium]
Can calling thc_interrupt_enable() here trigger a lockdep invalid wait
context splat when sharing the legacy INTx line with an IRQF_ONESHOT
handler?

thc_ipts_probe() requests a PCI_IRQ_INTX vector with IRQF_SHARED |
IRQF_COND_ONESHOT.  When another handler on that line uses IRQF_ONESHOT,
__setup_irq() promotes this action to IRQF_ONESHOT on an IO-APIC chip
without IRQCHIP_ONESHOT_SAFE, so __handle_irq_event_percpu() runs
thc_ipts_hardirq() in LD_WAIT_SPIN context without calling
lockdep_hardirq_threaded().  thc_interrupt_enable() then calls
regmap_write_bits() on dev->thc_regmap, which uses a non-raw spinlock_t
because thc_regmap_cfg sets .fast_io = true without .use_raw_spinlock =
true.

[ ... ]

> +void thc_ipts_recover(struct work_struct *work)
> +{
> +	struct thc_ipts *idev = container_of(work, struct thc_ipts,
> +					     recover_work);
[ ... ]
> +	WRITE_ONCE(idev->recovering, true);
> +	thc_interrupt_enable(idev->thc, false);
> +	synchronize_irq(idev->irq);
> +	/* A run that unmasked just before synchronize_irq() returned leaves
> +	 * the line open: mask it again, the write is idempotent.
> +	 */
> +	thc_interrupt_enable(idev->thc, false);
> +
> +	if (thc_rxdma_reset(idev->thc)) {
> +		/* Nothing left: keep the port masked until it restarts. */
> +		dev_err(idev->dev, "cannot reset the receive engine\n");
> +		return;
> +	}
[ ... ]
> +irqreturn_t thc_ipts_thread(int irq, void *data)
> +{
[ ... ]
> +	for (pass = 0; pass < THC_IPTS_IRQ_PASSES; pass++) {
> +		int mask;
> +
> +		/*
> +		 * The reset owns the status registers while it runs: a frame
> +		 * acknowledged here but not read is never announced again.
> +		 */
> +		if (READ_ONCE(idev->recovering)) {
> +			/* Nothing acknowledged, but the line is still ours. */
> +			ret = IRQ_HANDLED;
> +			break;
> +		}

[Severity: Medium]
Does returning IRQ_HANDLED whenever idev->recovering is set claim foreign
interrupts on the shared INTx line?

While thc_ipts_recover() is running, or permanently if thc_rxdma_reset()
fails and returns early with idev->recovering and idev->dma_ready still
true, the port interrupt is masked in hardware.  Every interrupt from
another device sharing the INTx line still causes thc_ipts_hardirq() to
write MMIO and return IRQ_WAKE_THREAD, and thc_ipts_thread() then writes
MMIO again and returns IRQ_HANDLED without checking any status registers,
adding a thread wakeup on every shared interrupt and defeating spurious
interrupt detection if a sibling device gets stuck.

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

  reply	other threads:[~2026-11-18  7:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  6:57 [PATCH v8 0/5] HID: intel-thc-hid: intel-ipts: support THC IPTS ports Emfox Zhou
2026-11-18  6:57 ` [PATCH v8 1/5] HID: intel-thc-hid: intel-ipts: bring up the port Emfox Zhou
2026-11-18  6:57 ` [PATCH v8 2/5] HID: intel-thc-hid: intel-ipts: receive reports Emfox Zhou
2026-11-18  7:19   ` sashiko-bot [this message]
2026-11-18  6:57 ` [PATCH v8 3/5] HID: intel-thc-hid: intel-ipts: add the HID device Emfox Zhou
2026-11-18  7:14   ` sashiko-bot
2026-11-18  6:57 ` [PATCH v8 4/5] HID: intel-thc-hid: intel-ipts: handle system sleep Emfox Zhou
2026-11-18  7:17   ` sashiko-bot
2026-11-18  6:57 ` [PATCH v8 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-220301@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.