All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative
@ 2026-08-07 15:14 Guangshuo Li
  2026-08-07 16:12 ` bluez.test.bot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Guangshuo Li @ 2026-08-07 15:14 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz, Matthias Brugger,
	AngeloGioacchino Del Regno, Sean Wang, linux-bluetooth,
	linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Guangshuo Li

btmtksdio_setup() calls pm_runtime_use_autosuspend() when runtime PM
is supported, but btmtksdio_remove() does not call the matching
pm_runtime_dont_use_autosuspend() when removing the device.

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 driver teardown, this reference is not dropped and usage_count
remains unbalanced.

Add the missing pm_runtime_dont_use_autosuspend() call in the remove
path before restoring the runtime PM usage reference.

This issue was found by manual code inspection.

Fixes: 7f3c563c575e ("Bluetooth: btmtksdio: Add runtime PM support to SDIO based Bluetooth")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/bluetooth/btmtksdio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
index c6f80c419e90..4e1012e90979 100644
--- a/drivers/bluetooth/btmtksdio.c
+++ b/drivers/bluetooth/btmtksdio.c
@@ -1480,6 +1480,9 @@ static void btmtksdio_remove(struct sdio_func *func)
 	if (test_bit(BTMTKSDIO_FUNC_ENABLED, &bdev->tx_state))
 		btmtksdio_close(hdev);
 
+	if (bdev->data->pm_runtime_supported)
+		pm_runtime_dont_use_autosuspend(bdev->dev);
+
 	/* Be consistent the state in btmtksdio_probe */
 	pm_runtime_get_noresume(bdev->dev);
 
-- 
2.43.0


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

* RE: Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative
  2026-08-07 15:14 [PATCH] Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative Guangshuo Li
@ 2026-08-07 16:12 ` bluez.test.bot
  2026-08-07 16:30 ` [PATCH] " patchwork-bot+bluetooth
  2026-08-18  8:32 ` Johan Hovold
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2026-08-07 16:12 UTC (permalink / raw)
  To: linux-bluetooth, lgs201920130244

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1142283

---Test result---

Test Summary:
CheckPatch                    PASS      0.51 seconds
VerifyFixes                   PASS      0.08 seconds
VerifySignedoff               PASS      0.43 seconds
GitLint                       PASS      0.32 seconds
SubjectPrefix                 PASS      0.06 seconds
BuildKernel                   PASS      26.47 seconds
CheckAllWarning               PASS      28.91 seconds
CheckSparse                   PASS      27.29 seconds
BuildKernel32                 PASS      25.48 seconds
CheckKernelLLVM               SKIP      0.00 seconds
TestRunnerSetup               PASS      487.34 seconds
IncrementalBuild              PASS      24.53 seconds

Details
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found


https://github.com/bluez/bluetooth-next/pull/549

---
Regards,
Linux Bluetooth


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

* Re: [PATCH] Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative
  2026-08-07 15:14 [PATCH] Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative Guangshuo Li
  2026-08-07 16:12 ` bluez.test.bot
@ 2026-08-07 16:30 ` patchwork-bot+bluetooth
  2026-08-18  8:32 ` Johan Hovold
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2026-08-07 16:30 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: marcel, luiz.dentz, matthias.bgg, angelogioacchino.delregno,
	sean.wang, linux-bluetooth, linux-kernel, linux-arm-kernel,
	linux-mediatek

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Fri,  7 Aug 2026 23:14:47 +0800 you wrote:
> btmtksdio_setup() calls pm_runtime_use_autosuspend() when runtime PM
> is supported, but btmtksdio_remove() does not call the matching
> pm_runtime_dont_use_autosuspend() when removing the device.
> 
> 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 driver teardown, this reference is not dropped and usage_count
> remains unbalanced.
> 
> [...]

Here is the summary with links:
  - Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative
    https://git.kernel.org/bluetooth/bluetooth-next/c/1e4acc44552b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




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

* Re: [PATCH] Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative
  2026-08-07 15:14 [PATCH] Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative Guangshuo Li
  2026-08-07 16:12 ` bluez.test.bot
  2026-08-07 16:30 ` [PATCH] " patchwork-bot+bluetooth
@ 2026-08-18  8:32 ` Johan Hovold
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2026-08-18  8:32 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: Marcel Holtmann, Luiz Augusto von Dentz, Matthias Brugger,
	AngeloGioacchino Del Regno, Sean Wang, linux-bluetooth,
	linux-kernel, linux-arm-kernel, linux-mediatek

On Fri, Aug 07, 2026 at 11:14:47PM +0800, Guangshuo Li wrote:
> btmtksdio_setup() calls pm_runtime_use_autosuspend() when runtime PM
> is supported, but btmtksdio_remove() does not call the matching
> pm_runtime_dont_use_autosuspend() when removing the device.
> 
> 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 driver teardown, this reference is not dropped and usage_count
> remains unbalanced.

I noticed the bluetooth ones have already been picked up, 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 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.

> Add the missing pm_runtime_dont_use_autosuspend() call in the remove
> path before restoring the runtime PM usage reference.
> 
> This issue was found by manual code inspection.
> 
> Fixes: 7f3c563c575e ("Bluetooth: btmtksdio: Add runtime PM support to SDIO based Bluetooth")
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
>  drivers/bluetooth/btmtksdio.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
> index c6f80c419e90..4e1012e90979 100644
> --- a/drivers/bluetooth/btmtksdio.c
> +++ b/drivers/bluetooth/btmtksdio.c
> @@ -1480,6 +1480,9 @@ static void btmtksdio_remove(struct sdio_func *func)
>  	if (test_bit(BTMTKSDIO_FUNC_ENABLED, &bdev->tx_state))
>  		btmtksdio_close(hdev);
>  
> +	if (bdev->data->pm_runtime_supported)
> +		pm_runtime_dont_use_autosuspend(bdev->dev);
> +
>  	/* Be consistent the state in btmtksdio_probe */
>  	pm_runtime_get_noresume(bdev->dev);

Johan


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

end of thread, other threads:[~2026-08-18  8:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07 15:14 [PATCH] Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative Guangshuo Li
2026-08-07 16:12 ` bluez.test.bot
2026-08-07 16:30 ` [PATCH] " patchwork-bot+bluetooth
2026-08-18  8:32 ` Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.