* [PATCH v2 1/2] Bluetooth: btmtksdio: Check function enabled before doing close
2025-04-22 1:21 [PATCH v2 0/2] Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove Chris Lu
@ 2025-04-22 1:21 ` Chris Lu
2025-04-22 1:21 ` [PATCH v2 2/2] Bluetooth: btmtksdio: Do close if SDIO card removed without close Chris Lu
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Chris Lu @ 2025-04-22 1:21 UTC (permalink / raw)
To: Marcel Holtmann, Johan Hedberg, Luiz Von Dentz
Cc: Sean Wang, Jiande Lu, Will Lee, SS Wu, Steve Lee, linux-bluetooth,
linux-kernel, linux-mediatek, Chris Lu
Check BTMTKSDIO_FUNC_ENABLED flag before doing close to prevent
btmtksdio_close been called twice.
Fixes: c4233afb9a ("Bluetooth: btmtksdio: Prevent enabling interrupts after IRQ handler removal")
Signed-off-by: Chris Lu <chris.lu@mediatek.com>
---
drivers/bluetooth/btmtksdio.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
index 566c136e83bf..3c66e3ee9834 100644
--- a/drivers/bluetooth/btmtksdio.c
+++ b/drivers/bluetooth/btmtksdio.c
@@ -723,6 +723,10 @@ static int btmtksdio_close(struct hci_dev *hdev)
{
struct btmtksdio_dev *bdev = hci_get_drvdata(hdev);
+ /* Skip btmtksdio_close if BTMTKSDIO_FUNC_ENABLED isn't set */
+ if (!test_bit(BTMTKSDIO_FUNC_ENABLED, &bdev->tx_state))
+ return 0;
+
sdio_claim_host(bdev->func);
/* Disable interrupt */
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v2 2/2] Bluetooth: btmtksdio: Do close if SDIO card removed without close
2025-04-22 1:21 [PATCH v2 0/2] Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove Chris Lu
2025-04-22 1:21 ` [PATCH v2 1/2] Bluetooth: btmtksdio: Check function enabled before doing close Chris Lu
@ 2025-04-22 1:21 ` Chris Lu
2025-04-22 13:30 ` [PATCH v2 0/2] Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove patchwork-bot+bluetooth
2025-05-21 15:23 ` patchwork-bot+bluetooth
3 siblings, 0 replies; 5+ messages in thread
From: Chris Lu @ 2025-04-22 1:21 UTC (permalink / raw)
To: Marcel Holtmann, Johan Hedberg, Luiz Von Dentz
Cc: Sean Wang, Jiande Lu, Will Lee, SS Wu, Steve Lee, linux-bluetooth,
linux-kernel, linux-mediatek, Chris Lu
To prevent Bluetooth SDIO card from be physically removed suddenly,
driver needs to ensure btmtksdio_close is called before
btmtksdio_remove to disable interrupts and txrx workqueue.
Fixes: c4233afb9a ("Bluetooth: btmtksdio: Prevent enabling interrupts after IRQ handler removal")
Signed-off-by: Chris Lu <chris.lu@mediatek.com>
---
drivers/bluetooth/btmtksdio.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
index 3c66e3ee9834..c16a3518b8ff 100644
--- a/drivers/bluetooth/btmtksdio.c
+++ b/drivers/bluetooth/btmtksdio.c
@@ -1447,11 +1447,15 @@ static void btmtksdio_remove(struct sdio_func *func)
if (!bdev)
return;
+ hdev = bdev->hdev;
+
+ /* Make sure to call btmtksdio_close before removing sdio card */
+ if (test_bit(BTMTKSDIO_FUNC_ENABLED, &bdev->tx_state))
+ btmtksdio_close(hdev);
+
/* Be consistent the state in btmtksdio_probe */
pm_runtime_get_noresume(bdev->dev);
- hdev = bdev->hdev;
-
sdio_set_drvdata(func, NULL);
hci_unregister_dev(hdev);
hci_free_dev(hdev);
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2 0/2] Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove
2025-04-22 1:21 [PATCH v2 0/2] Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove Chris Lu
2025-04-22 1:21 ` [PATCH v2 1/2] Bluetooth: btmtksdio: Check function enabled before doing close Chris Lu
2025-04-22 1:21 ` [PATCH v2 2/2] Bluetooth: btmtksdio: Do close if SDIO card removed without close Chris Lu
@ 2025-04-22 13:30 ` patchwork-bot+bluetooth
2025-05-21 15:23 ` patchwork-bot+bluetooth
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2025-04-22 13:30 UTC (permalink / raw)
To: Chris Lu
Cc: marcel, johan.hedberg, luiz.dentz, sean.wang, jiande.lu,
will-cy.lee, ss.wu, steve.lee, linux-bluetooth, linux-kernel,
linux-mediatek
Hello:
This series was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Tue, 22 Apr 2025 09:21:54 +0800 you wrote:
> If Bluetooth SDIO card is unexpectedly removed due to hardware removal
> or SDIO issue, it is possible for remove to be called before close.
> If an interrupt occurs during this process, it may cause kernel panic.
> Therefore, it is necessary to ensure that close is executed before
> remove to stop interrupts and cancel txrx workqueue.
>
> Chris Lu (2):
> Bluetooth: btmtksdio: Check function enabled before doing close
> Bluetooth: btmtksdio: Do close if SDIO card removed without close
>
> [...]
Here is the summary with links:
- [v2,1/2] Bluetooth: btmtksdio: Check function enabled before doing close
https://git.kernel.org/bluetooth/bluetooth-next/c/04c96a7ace25
- [v2,2/2] Bluetooth: btmtksdio: Do close if SDIO card removed without close
https://git.kernel.org/bluetooth/bluetooth-next/c/e0af21b30c82
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] 5+ messages in thread* Re: [PATCH v2 0/2] Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove
2025-04-22 1:21 [PATCH v2 0/2] Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove Chris Lu
` (2 preceding siblings ...)
2025-04-22 13:30 ` [PATCH v2 0/2] Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove patchwork-bot+bluetooth
@ 2025-05-21 15:23 ` patchwork-bot+bluetooth
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2025-05-21 15:23 UTC (permalink / raw)
To: Chris Lu
Cc: marcel, johan.hedberg, luiz.dentz, sean.wang, jiande.lu,
will-cy.lee, ss.wu, steve.lee, linux-bluetooth, linux-kernel,
linux-mediatek
Hello:
This series was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Tue, 22 Apr 2025 09:21:54 +0800 you wrote:
> If Bluetooth SDIO card is unexpectedly removed due to hardware removal
> or SDIO issue, it is possible for remove to be called before close.
> If an interrupt occurs during this process, it may cause kernel panic.
> Therefore, it is necessary to ensure that close is executed before
> remove to stop interrupts and cancel txrx workqueue.
>
> Chris Lu (2):
> Bluetooth: btmtksdio: Check function enabled before doing close
> Bluetooth: btmtksdio: Do close if SDIO card removed without close
>
> [...]
Here is the summary with links:
- [v2,1/2] Bluetooth: btmtksdio: Check function enabled before doing close
https://git.kernel.org/bluetooth/bluetooth-next/c/07e90048e356
- [v2,2/2] Bluetooth: btmtksdio: Do close if SDIO card removed without close
https://git.kernel.org/bluetooth/bluetooth-next/c/0b6d58bc6ea8
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] 5+ messages in thread