[PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown

Guangshuo Li posted 1 patch 1 month, 3 weeks ago
drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
Posted by Guangshuo Li 1 month, 3 weeks ago
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
Re: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
Posted by Johan Hovold 1 month, 1 week ago
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
Re: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
Posted by Jiri Kosina 1 month, 1 week ago
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
Re: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
Posted by Johan Hovold 1 month, 1 week ago
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
Re: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
Posted by Jiri Kosina 1 month, 1 week ago
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
Re: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
Posted by Jiri Kosina 1 month, 2 weeks ago
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
RE: [PATCH] HID: intel-thc-hid: intel-quicki2c: fix autosuspend cleanup during teardown
Posted by Xu, Even 1 month, 2 weeks ago

> -----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