public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove
@ 2025-04-21  7:29 Chris Lu
  2025-04-21  7:29 ` [PATCH v1 1/2] Bluetooth: btmtksdio: Check function enabled before doing close Chris Lu
  2025-04-21  7:29 ` [PATCH v1 2/2] Bluetooth: btmtksdio: Do close if SDIO card removed without close Chris Lu
  0 siblings, 2 replies; 7+ messages in thread
From: Chris Lu @ 2025-04-21  7:29 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

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

 drivers/bluetooth/btmtksdio.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

-- 
2.45.2


^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH v2 1/2] Bluetooth: btmtksdio: Check function enabled before doing close
@ 2025-04-22  1:21 Chris Lu
  2025-04-22  3:07 ` Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove bluez.test.bot
  0 siblings, 1 reply; 7+ 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] 7+ messages in thread

end of thread, other threads:[~2025-04-22  3:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-21  7:29 [PATCH v1 0/2] Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove Chris Lu
2025-04-21  7:29 ` [PATCH v1 1/2] Bluetooth: btmtksdio: Check function enabled before doing close Chris Lu
2025-04-21 14:01   ` Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove bluez.test.bot
2025-04-21 19:19   ` [PATCH v1 1/2] Bluetooth: btmtksdio: Check function enabled before doing close Luiz Augusto von Dentz
2025-04-21  7:29 ` [PATCH v1 2/2] Bluetooth: btmtksdio: Do close if SDIO card removed without close Chris Lu
2025-04-21 19:19   ` Luiz Augusto von Dentz
  -- strict thread matches above, loose matches on Subject: below --
2025-04-22  1:21 [PATCH v2 1/2] Bluetooth: btmtksdio: Check function enabled before doing close Chris Lu
2025-04-22  3:07 ` Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove bluez.test.bot

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