Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Qianhui Xu" <xiaqinghuan@mail.ustc.edu.cn>, linux-input@vger.kernel.org
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2 6/6] Input: aw86927 - stop playback over suspend and on shutdown
Date: Tue, 17 Nov 2026 05:46:20 +0000	[thread overview]
Message-ID: <sashiko-outbox-218219@kernel.org> (raw)
In-Reply-To: <20261117052112.32527-7-xiaqinghuan@mail.ustc.edu.cn>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] Input: aw86927: race in aw86927_close() and unbind queues
  play_work after stop
- [Low] Input: aw86927: commit message and comment mismatch on
  suspend/shutdown
--

commit 10d522b2154a0fe403051ae8e5379871fd0348a4
Author: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>

Input: aw86927 - stop playback over suspend and on shutdown

This commit adds system suspend, resume, and shutdown callbacks to stop
haptic playback and hold the chip in reset, and registers a devm action to
assert the reset GPIO on unbind or probe failure.

> diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
> index 1dbcba7988316..35a342131edff 100644
> --- a/drivers/input/misc/aw86927.c
> +++ b/drivers/input/misc/aw86927.c
[ ... ]
> @@ -444,6 +451,7 @@ static void aw86927_close(struct input_dev *input)
>  	int err;
>  
>  	cancel_work_sync(&haptics->play_work);
> +	WRITE_ONCE(haptics->level, 0);
>  
>  	err = aw86927_stop(haptics);
>  	if (err)
[ ... ]
> @@ -800,6 +809,13 @@ static int aw86927_detect(struct aw86927_data *haptics)
>  	return 0;
>  }
>  
> +static void aw86927_reset(void *data)
> +{
> +	struct aw86927_data *haptics = data;
> +
> +	gpiod_set_value_cansleep(haptics->reset_gpio, 1);
> +}
> +
>  static int aw86927_probe(struct i2c_client *client)
>  {
>  	struct aw86927_data *haptics;
> @@ -828,6 +844,10 @@ static int aw86927_probe(struct i2c_client *client)
>  		return dev_err_probe(haptics->dev, PTR_ERR(haptics->reset_gpio),
>  				     "Failed to get reset gpio\n");
>  
> +	err = devm_add_action_or_reset(haptics->dev, aw86927_reset, haptics);
> +	if (err)
> +		return err;

[Severity: High]
Can haptics->play_work be scheduled after aw86927_close() and still be
running during driver unbind?

Clearing haptics->level in aw86927_close() while an ff-memless effect timer
is still armed lets ml_effect_timer() pass the READ_ONCE(haptics->level) ==
level check in aw86927_haptics_play() and queue haptics->play_work again.
This happens when an open device with an active effect is inhibited via
input_inhibit_device(), which calls dev->close() without calling
dev->flush() to stop ml->timer, or when input_flush_device() is interrupted
by a signal before input_close_device() runs.

If the driver is then unbound, input_close_device() skips aw86927_close() on
an inhibited device while input_flush_device() queues haptics->play_work to
stop the effect, and unlike aw86927_shutdown(), the devm aw86927_reset()
action does not call disable_work_sync(&haptics->play_work):

CPU0                                  CPU1 (kworker)
i2c_device_remove()
  ...
  __input_unregister_device()
    evdev_cleanup()
      input_flush_device()
        ...
        aw86927_haptics_play()
          schedule_work(&haptics->play_work)
      input_close_device()
        /* skipped: dev->inhibited */
  devres_release_all()
    aw86927_reset()
    /* regmap and haptics freed */
                                      aw86927_haptics_play_work()
                                        aw86927_stop(haptics)
                                          regmap_write(haptics->regmap, ...)
                                          <-- use-after-free

[ ... ]

> @@ -899,6 +919,51 @@ static int aw86927_probe(struct i2c_client *client)
>  	return 0;
>  }
>  
> +static void aw86927_shutdown(struct i2c_client *client)
> +{
> +	struct aw86927_data *haptics = i2c_get_clientdata(client);
> +
> +	disable_work_sync(&haptics->play_work);
> +	aw86927_reset(haptics);
> +}
> +
> +static int aw86927_suspend(struct device *dev)
> +{
> +	struct aw86927_data *haptics = dev_get_drvdata(dev);
> +	int err;
> +
> +	guard(mutex)(&haptics->input_dev->mutex);
> +
> +	/* Block events from the memless effect timer before draining the work. */
> +	scoped_guard(spinlock_irq, &haptics->input_dev->event_lock)
> +		haptics->suspended = true;
> +
> +	cancel_work_sync(&haptics->play_work);
> +	err = aw86927_stop(haptics);

[Severity: Low]
This isn't a bug, but the commit message and the comment in
aw86927_haptics_play() do not match what the suspend and shutdown callbacks
do.

The commit message states that both paths stop playback, drain the work item
and park the part in reset, whereas aw86927_suspend() only puts the chip into
standby via aw86927_stop() without asserting reset, and aw86927_shutdown()
asserts reset via aw86927_reset() without calling aw86927_stop().  In
addition, the comment in aw86927_haptics_play() says the chip is powered
down and a queued event would only fail, but during suspend the chip is only
in standby and a queued event would re-arm playback over I2C.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117052112.32527-1-xiaqinghuan@mail.ustc.edu.cn?part=6

      reply	other threads:[~2026-11-17  5:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  5:21 [PATCH v2 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
2026-11-17  5:21 ` [PATCH v2 1/6] Input: aw86927 - fix the 7 V boost reference for AW86938 Qianhui Xu
2026-11-17  5:21 ` [PATCH v2 2/6] Input: aw86927 - widen the AW86938 boost mode mask Qianhui Xu
2026-11-17  5:21 ` [PATCH v2 3/6] dt-bindings: input: awinic,aw86927: document the AW86937 variant Qianhui Xu
2026-11-17  5:21 ` [PATCH v2 4/6] Input: aw86927 - add support for Awinic AW86937 Qianhui Xu
2026-11-17  5:21 ` [PATCH v2 5/6] Input: aw86927 - handle the AW8693X play and boost register layout Qianhui Xu
2026-11-17  5:21 ` [PATCH v2 6/6] Input: aw86927 - stop playback over suspend and on shutdown Qianhui Xu
2026-11-17  5:46   ` 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=sashiko-outbox-218219@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.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 \
    --cc=xiaqinghuan@mail.ustc.edu.cn \
    /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