Linux Input/HID development
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: sashiko-bot@kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH 04/12] HID: rmi: fix device lifecycle, suspend, and reset work handling
Date: Sun, 15 Nov 2026 18:31:11 -0800	[thread overview]
Message-ID: <aef5b22471cedda012e99a7dc82c6a20@gmail.com> (raw)
In-Reply-To: <sashiko-outbox-214211@kernel.org>

On Sat, Nov 14, 2026 at 06:21:03AM +0000, sashiko-bot@kernel.org wrote:
> > +	set_bit(RMI_SUSPENDED, &data->flags);
> > +	cancel_work_sync(&data->reset_work);
> > +
> 
> [Severity: Medium]
> Can rmi_event() still queue data->reset_work after cancel_work_sync() returns
> in rmi_suspend()?
> 
> Low-level HID transport drivers such as i2c-hid and usbhid invoke
> hid_driver_suspend() before disabling hardware interrupts or stopping input
> URBs, and without holding hdev->driver_input_lock:
...
> Neither rmi_reset_work() nor rmi_reset_attn_mode() checks RMI_SUSPENDED, so
> reset_work will issue bus transfers and reconfigure RMI functions concurrently
> with rmi_driver_suspend() or while the device is suspended.  Using
> disable_work_sync() in rmi_suspend() paired with enable_work() on error and in
> rmi_post_resume() would close this race.

Good point, using disable_work_sync() and enable_work() across suspend
and resume avoids the race with rmi_event() and also removes the need
for the RMI_SUSPENDED flag. I will update the patch accordingly.

> >  	/* Make sure the HID device is ready to receive events */
> >  	ret = hid_hw_open(hdev);
> >  	if (ret)
> > -		return ret;
> > +		goto out;
...
> > -out:
> >  	hid_hw_close(hdev);
> > +
> > +out:
> > +	clear_bit(RMI_SUSPENDED, &data->flags);
> >  	return ret;
> >  }
> 
> [Severity: Medium]
> Does jumping to out when hid_hw_open() fails leave data->rmi_irq disabled?
> 
> If hid_hw_open() returns an error (for example, -EINTR from
> mutex_lock_killable(&hdev->ll_open_lock)), jumping to out clears RMI_SUSPENDED
> without calling rmi_driver_resume().  Because rmi_suspend() disabled the
> transport interrupt via rmi_driver_suspend() -> rmi_disable_irq(), the device
> is left active after resume with data->rmi_irq permanently disabled, dropping
> all subsequent attention reports.

hid_hw_open() is required here so the low-level HID transport is open
to receive read data reports while rmi_reset_attn_mode() and
rmi_driver_resume() talk to the device. If hid_hw_open() fails we
cannot communicate with the hardware to resume RMI functions anyway,
though reset_work still needs to be re-enabled so the work disable
depth stays balanced across suspend and resume cycles. Beyond that,
RMI4 suspend and resume handling in the core and transport drivers
needs broader rework anyway, which will be addressed in follow-up
changes.

Thanks.

-- 
Dmitry

  reply	other threads:[~2026-11-16  2:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14  5:59 [PATCH 00/12] HID: rmi: Fix report handling, device lifecycle, and clean up code Dmitry Torokhov
2026-11-14  5:59 ` [PATCH 01/12] HID: rmi: return error on short output report writes Dmitry Torokhov
2026-11-14  5:59 ` [PATCH 02/12] HID: rmi: only strip trailing 0xff bytes from attention reports Dmitry Torokhov
2026-11-14  5:59 ` [PATCH 03/12] HID: rmi: validate read data report and protocol transfer bounds Dmitry Torokhov
2026-11-14  5:59 ` [PATCH 04/12] HID: rmi: fix device lifecycle, suspend, and reset work handling Dmitry Torokhov
2026-11-14  6:21   ` sashiko-bot
2026-11-16  2:31     ` Dmitry Torokhov [this message]
2026-11-14  5:59 ` [PATCH 05/12] HID: rmi: re-select page 0 across device resets Dmitry Torokhov
2026-11-14  5:59 ` [PATCH 06/12] HID: rmi: avoid GFP_ATOMIC allocation with hard IRQs disabled Dmitry Torokhov
2026-11-14  5:59 ` [PATCH 07/12] HID: rmi: do not mutate shared platform data template Dmitry Torokhov
2026-11-14  5:59 ` [PATCH 08/12] HID: rmi: use put_unaligned_le16() to populate output reports Dmitry Torokhov
2026-11-14  5:59 ` [PATCH 09/12] HID: rmi: use scope-based cleanup for mode feature buffer Dmitry Torokhov
2026-11-14  6:00 ` [PATCH 10/12] HID: rmi: switch to scoped mutex guards Dmitry Torokhov
2026-11-14  6:00 ` [PATCH 11/12] HID: rmi: remove dead code and reorder report write helper Dmitry Torokhov
2026-11-14  6:00 ` [PATCH 12/12] HID: rmi: clean up coding style and logging Dmitry Torokhov

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=aef5b22471cedda012e99a7dc82c6a20@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-bot@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