mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
@ 2026-08-08 14:57 Guangshuo Li
  2026-08-10  0:53 ` Xu, Even
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Guangshuo Li @ 2026-08-08 14:57 UTC (permalink / raw)
  To: Even Xu, Xinpeng Sun, Jiri Kosina, Benjamin Tissoires,
	Sakari Ailus, Guangshuo Li, Mark Pearson, Srinivas Pandruvada,
	linux-input, linux-kernel
  Cc: stable

quicki2c_probe() calls pm_runtime_use_autosuspend(), but
quicki2c_remove() does not call the matching
pm_runtime_dont_use_autosuspend() during teardown.

If the autosuspend delay is set to a negative value while autosuspend
is enabled, the runtime PM core increments usage_count to prevent
runtime suspend. Without calling pm_runtime_dont_use_autosuspend()
during teardown, this reference is not dropped.

The documentation for pm_runtime_use_autosuspend() also notes that it
is important to undo it with pm_runtime_dont_use_autosuspend() at
driver exit time, unless runtime PM was initially enabled with
devm_pm_runtime_enable().

Add the missing pm_runtime_dont_use_autosuspend() call to the driver
remove path.

This issue was found by manual code inspection.

Fixes: 5f420e8215c6 ("HID: intel-thc-hid: intel-quicki2c: Add PM implementation")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
index 46d3e9a01999..4126c2408d98 100644
--- a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
+++ b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
@@ -774,6 +774,7 @@ static void quicki2c_remove(struct pci_dev *pdev)
 	quicki2c_hid_remove(qcdev);
 	quicki2c_dma_deinit(qcdev);
 
+	pm_runtime_dont_use_autosuspend(qcdev->dev);
 	pm_runtime_get_noresume(qcdev->dev);
 
 	quicki2c_dev_deinit(qcdev);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
  2026-08-08 14:57 [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown Guangshuo Li
@ 2026-08-10  0:53 ` Xu, Even
  2026-08-14 13:13 ` Jiri Kosina
  2026-08-18  8:39 ` Johan Hovold
  2 siblings, 0 replies; 7+ messages in thread
From: Xu, Even @ 2026-08-10  0:53 UTC (permalink / raw)
  To: Guangshuo Li, Sun, Xinpeng, Jiri Kosina, Benjamin Tissoires,
	Sakari Ailus, Mark Pearson, Srinivas Pandruvada, linux-input,
	linux-kernel
  Cc: stable



> -----Original Message-----
> From: Guangshuo Li <lgs201920130244@gmail.com>
> Sent: Saturday, August 8, 2026 10:58 PM
> To: Xu, Even <even.xu@intel.com>; Sun, Xinpeng <xinpeng.sun@intel.com>; Jiri
> Kosina <jikos@kernel.org>; Benjamin Tissoires <bentiss@kernel.org>; Sakari Ailus
> <sakari.ailus@linux.intel.com>; Guangshuo Li <lgs201920130244@gmail.com>;
> Mark Pearson <mpearson-lenovo@squebb.ca>; Srinivas Pandruvada
> <srinivas.pandruvada@linux.intel.com>; linux-input@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Cc: stable@vger.kernel.org
> Subject: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during
> teardown
> 
> quicki2c_probe() calls pm_runtime_use_autosuspend(), but
> quicki2c_remove() does not call the matching
> pm_runtime_dont_use_autosuspend() during teardown.
> 
> If the autosuspend delay is set to a negative value while autosuspend is enabled,
> the runtime PM core increments usage_count to prevent runtime suspend.
> Without calling pm_runtime_dont_use_autosuspend() during teardown, this
> reference is not dropped.
> 
> The documentation for pm_runtime_use_autosuspend() also notes that it is
> important to undo it with pm_runtime_dont_use_autosuspend() at driver exit
> time, unless runtime PM was initially enabled with devm_pm_runtime_enable().
> 
> Add the missing pm_runtime_dont_use_autosuspend() call to the driver remove
> path.
> 
> This issue was found by manual code inspection.
> 
> Fixes: 5f420e8215c6 ("HID: intel-thc-hid: intel-quicki2c: Add PM
> implementation")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
>  drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
> b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
> index 46d3e9a01999..4126c2408d98 100644
> --- a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
> +++ b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
> @@ -774,6 +774,7 @@ static void quicki2c_remove(struct pci_dev *pdev)
>  	quicki2c_hid_remove(qcdev);
>  	quicki2c_dma_deinit(qcdev);
> 
> +	pm_runtime_dont_use_autosuspend(qcdev->dev);

Thanks for the patch!
Reviewed-by: Even Xu <even.xu@intel.com>

>  	pm_runtime_get_noresume(qcdev->dev);
> 
>  	quicki2c_dev_deinit(qcdev);
> --
> 2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
  2026-08-08 14:57 [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown Guangshuo Li
  2026-08-10  0:53 ` Xu, Even
@ 2026-08-14 13:13 ` Jiri Kosina
  2026-08-18  8:39 ` Johan Hovold
  2 siblings, 0 replies; 7+ messages in thread
From: Jiri Kosina @ 2026-08-14 13:13 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: Even Xu, Xinpeng Sun, Benjamin Tissoires, Sakari Ailus,
	Mark Pearson, Srinivas Pandruvada, linux-input, linux-kernel,
	stable

On Sat, 8 Aug 2026, Guangshuo Li wrote:

> quicki2c_probe() calls pm_runtime_use_autosuspend(), but
> quicki2c_remove() does not call the matching
> pm_runtime_dont_use_autosuspend() during teardown.
> 
> If the autosuspend delay is set to a negative value while autosuspend
> is enabled, the runtime PM core increments usage_count to prevent
> runtime suspend. Without calling pm_runtime_dont_use_autosuspend()
> during teardown, this reference is not dropped.
> 
> The documentation for pm_runtime_use_autosuspend() also notes that it
> is important to undo it with pm_runtime_dont_use_autosuspend() at
> driver exit time, unless runtime PM was initially enabled with
> devm_pm_runtime_enable().
> 
> Add the missing pm_runtime_dont_use_autosuspend() call to the driver
> remove path.
> 
> This issue was found by manual code inspection.
> 
> Fixes: 5f420e8215c6 ("HID: intel-thc-hid: intel-quicki2c: Add PM implementation")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>

Applied, thanks.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
  2026-08-08 14:57 [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown Guangshuo Li
  2026-08-10  0:53 ` Xu, Even
  2026-08-14 13:13 ` Jiri Kosina
@ 2026-08-18  8:39 ` Johan Hovold
  2026-08-20 11:33   ` Jiri Kosina
  2 siblings, 1 reply; 7+ messages in thread
From: Johan Hovold @ 2026-08-18  8:39 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: Even Xu, Xinpeng Sun, Jiri Kosina, Benjamin Tissoires,
	Sakari Ailus, Mark Pearson, Srinivas Pandruvada, linux-input,
	linux-kernel, stable

On Sat, Aug 08, 2026 at 10:57:48PM +0800, Guangshuo Li wrote:
> quicki2c_probe() calls pm_runtime_use_autosuspend(), but
> quicki2c_remove() does not call the matching
> pm_runtime_dont_use_autosuspend() during teardown.
> 
> If the autosuspend delay is set to a negative value while autosuspend
> is enabled, the runtime PM core increments usage_count to prevent
> runtime suspend. Without calling pm_runtime_dont_use_autosuspend()
> during teardown, this reference is not dropped.

I see that the HID ones have already been merged, but for the record:

As I've explained elsewhere, this is just misleading. There is no usage
count leak here as the count is balanced whenever the user re-enables
autosuspend through sysfs (by writing a non-negative timeout).

Drivers should clean up after themselves and disable autosuspend, but
this is more of a clean up than a fix and should not be backported.

You've sent upwards of 60 of these in the matter of a just a few days,
some of which have even been picked up. Please send follow-ups (replies
or v2s) as soon as possible to prevent further of these from getting
merged.

> The documentation for pm_runtime_use_autosuspend() also notes that it
> is important to undo it with pm_runtime_dont_use_autosuspend() at
> driver exit time, unless runtime PM was initially enabled with
> devm_pm_runtime_enable().
> 
> Add the missing pm_runtime_dont_use_autosuspend() call to the driver
> remove path.
> 
> This issue was found by manual code inspection.
> 
> Fixes: 5f420e8215c6 ("HID: intel-thc-hid: intel-quicki2c: Add PM implementation")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>

Johan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
  2026-08-18  8:39 ` Johan Hovold
@ 2026-08-20 11:33   ` Jiri Kosina
  2026-08-20 11:41     ` Johan Hovold
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Kosina @ 2026-08-20 11:33 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Guangshuo Li, Even Xu, Xinpeng Sun, Benjamin Tissoires,
	Sakari Ailus, Mark Pearson, Srinivas Pandruvada, linux-input,
	linux-kernel, stable

On Tue, 18 Aug 2026, Johan Hovold wrote:

> > quicki2c_probe() calls pm_runtime_use_autosuspend(), but
> > quicki2c_remove() does not call the matching
> > pm_runtime_dont_use_autosuspend() during teardown.
> > 
> > If the autosuspend delay is set to a negative value while autosuspend
> > is enabled, the runtime PM core increments usage_count to prevent
> > runtime suspend. Without calling pm_runtime_dont_use_autosuspend()
> > during teardown, this reference is not dropped.
> 
> I see that the HID ones have already been merged, but for the record:
> 
> As I've explained elsewhere, this is just misleading. There is no usage
> count leak here as the count is balanced whenever the user re-enables
> autosuspend through sysfs (by writing a non-negative timeout).
> 
> Drivers should clean up after themselves and disable autosuspend, but
> this is more of a clean up than a fix and should not be backported.

Hi Johan

unfrtounately the HID one was already merged as is.

Looking at this now again in more detail, I believe the code change is 
actually OK, but the changelog is misleading. Or am I missing something?

Thanks,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
  2026-08-20 11:33   ` Jiri Kosina
@ 2026-08-20 11:41     ` Johan Hovold
  2026-08-20 11:47       ` Jiri Kosina
  0 siblings, 1 reply; 7+ messages in thread
From: Johan Hovold @ 2026-08-20 11:41 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Guangshuo Li, Even Xu, Xinpeng Sun, Benjamin Tissoires,
	Sakari Ailus, Mark Pearson, Srinivas Pandruvada, linux-input,
	linux-kernel, stable

Hi Jiri,

On Thu, Aug 20, 2026 at 01:33:16PM +0200, Jiri Kosina wrote:
> On Tue, 18 Aug 2026, Johan Hovold wrote:
> 
> > > quicki2c_probe() calls pm_runtime_use_autosuspend(), but
> > > quicki2c_remove() does not call the matching
> > > pm_runtime_dont_use_autosuspend() during teardown.
> > > 
> > > If the autosuspend delay is set to a negative value while autosuspend
> > > is enabled, the runtime PM core increments usage_count to prevent
> > > runtime suspend. Without calling pm_runtime_dont_use_autosuspend()
> > > during teardown, this reference is not dropped.
> > 
> > I see that the HID ones have already been merged, but for the record:
> > 
> > As I've explained elsewhere, this is just misleading. There is no usage
> > count leak here as the count is balanced whenever the user re-enables
> > autosuspend through sysfs (by writing a non-negative timeout).
> > 
> > Drivers should clean up after themselves and disable autosuspend, but
> > this is more of a clean up than a fix and should not be backported.

> Looking at this now again in more detail, I believe the code change is 
> actually OK, but the changelog is misleading. Or am I missing something?

Indeed, the change itself is fine, but the commit message is misleading
and these do not need to be backported.

Johan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
  2026-08-20 11:41     ` Johan Hovold
@ 2026-08-20 11:47       ` Jiri Kosina
  0 siblings, 0 replies; 7+ messages in thread
From: Jiri Kosina @ 2026-08-20 11:47 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Guangshuo Li, Even Xu, Xinpeng Sun, Benjamin Tissoires,
	Sakari Ailus, Mark Pearson, Srinivas Pandruvada, linux-input,
	linux-kernel, stable

On Thu, 20 Aug 2026, Johan Hovold wrote:

> > Looking at this now again in more detail, I believe the code change is 
> > actually OK, but the changelog is misleading. Or am I missing something?
> 
> Indeed, the change itself is fine, but the commit message is misleading
> and these do not need to be backported.

Ack, agreed. Thanks a lot for catching this, Johan.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-08-20 11:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-08 14:57 [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown Guangshuo Li
2026-08-10  0:53 ` Xu, Even
2026-08-14 13:13 ` Jiri Kosina
2026-08-18  8:39 ` Johan Hovold
2026-08-20 11:33   ` Jiri Kosina
2026-08-20 11:41     ` Johan Hovold
2026-08-20 11:47       ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®