Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Golle" <daniel@makrotopia.org>
Cc: dmitry.torokhov@gmail.com, devicetree@vger.kernel.org,
	conor+dt@kernel.org, robh@kernel.org,
	linux-input@vger.kernel.org
Subject: Re: [PATCH 4/4] Input: hynitron-cst816x: time out gesture key release
Date: Thu, 01 Oct 2026 11:01:33 +0000	[thread overview]
Message-ID: <20261001110133.AC8AF1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <ea9fa494cfb0a10cee72795a60ed5481fb227de5.1790851590.git.daniel@makrotopia.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] input: spurious key release due to timer callback race
--

commit 84ec9fce5971ed83d872b86322e5cd6170da5358
Author: Daniel Golle <daniel@makrotopia.org>

Input: hynitron-cst816x: time out gesture key release

This commit adds a 40ms timer to release gesture keys if a new touch
event with a gesture code is not reported in time. It helps prevent
keys from remaining stuck in the pressed state when the panel stops
sending events.

> diff --git a/drivers/input/touchscreen/hynitron-cst816x.c b/drivers/input/touchscreen/hynitron-cst816x.c
> index e2093518e8af1..30f8ea314ed2c 100644
> --- a/drivers/input/touchscreen/hynitron-cst816x.c
> +++ b/drivers/input/touchscreen/hynitron-cst816x.c
[ ... ]
> @@ -177,33 +184,65 @@ static void cst816x_release_keys(struct cst816x_priv *priv)
[ ... ]
> +static void cst816x_release_timeout(struct timer_list *t)
> +{
> +	struct cst816x_priv *priv = timer_container_of(priv, t, release_timer);
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&priv->lock, flags);
> +
> +	if (cst816x_release_keys(priv))
> +		input_sync(priv->input);
> +
> +	spin_unlock_irqrestore(&priv->lock, flags);
> +}

[Severity: Medium]
Could this unconditionally release keys even if the timer was just
concurrently re-armed by the IRQ handler?

If the timer softirq and the threaded IRQ handler (cst816x_irq_cb) run
concurrently on different CPUs, the timer callback might spin waiting for
the lock while the IRQ handler is reporting a new key press and re-arming
the timer.

Once the IRQ handler drops the lock, the timer callback acquires it and
unconditionally executes cst816x_release_keys(), undoing the IRQ handler's
action and causing a spurious release of gesture keys.

Would it be safer to check if the timer was re-enqueued (e.g., via
timer_pending()) while waiting for the lock before releasing the keys?

>  static irqreturn_t cst816x_irq_cb(int irq, void *cookie)
>  {
>  	struct cst816x_priv *priv = cookie;
>  	struct cst816x_touch tch;
> +	unsigned long flags;
>  
>  	if (!cst816x_process_touch(priv, &tch))
>  		return IRQ_HANDLED;
>  
> +	spin_lock_irqsave(&priv->lock, flags);
> +
>  	touchscreen_report_pos(priv->input, &priv->prop,
>  			       tch.abs_x, tch.abs_y, false);
>  
> -	if (tch.gest)
> +	if (tch.gest) {
>  		input_report_key(priv->input,
>  				 priv->keycode[cst816x_gest_idx(tch.gest)], 1);
> -	else
> +		mod_timer(&priv->release_timer,
> +			  jiffies + msecs_to_jiffies(CST816X_GEST_HOLD_MS));

[Severity: Medium]
Does re-arming the timer here race with the timer callback executing on
another CPU?

Because the timer callback does not check if the timer was re-armed, the
newly reported key press here could be immediately reversed by the racing
timer callback once the IRQ handler releases the lock.

> +	} else {
> +		timer_delete(&priv->release_timer);
>  		cst816x_release_keys(priv);
> +	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/d18629ede3f2fd5a08d0cbdaf82f4254e89500ed.1790851590.git.daniel@makrotopia.org?part=4

      reply	other threads:[~2026-10-01 11:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 10:52 [PATCH 0/4] Input: hynitron-cst816x: axis properties and gesture keys Daniel Golle
2026-10-01 10:52 ` [PATCH 1/4] dt-bindings: input: touchscreen: hynitron,cst816x: configure axes Daniel Golle
2026-10-01 11:02   ` sashiko-bot
2026-10-01 19:01   ` Conor Dooley
2026-10-01 10:52 ` [PATCH 2/4] Input: hynitron-cst816x: respect touchscreen DT properties Daniel Golle
2026-10-01 10:53 ` [PATCH 3/4] Input: hynitron-cst816x: release gesture keys Daniel Golle
2026-10-01 11:00   ` sashiko-bot
2026-10-01 10:53 ` [PATCH 4/4] Input: hynitron-cst816x: time out gesture key release Daniel Golle
2026-10-01 11:01   ` sashiko-bot [this message]

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=20261001110133.AC8AF1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=daniel@makrotopia.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=robh@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