* [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 v1 1/2] Bluetooth: btmtksdio: Check function enabled before doing close
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 ` 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
1 sibling, 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
Check BTMTKSDIO_FUNC_ENABLED flag before doing close to prevent
btmtksdio_close been called twice.
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* RE: Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove
2025-04-21 7:29 ` [PATCH v1 1/2] Bluetooth: btmtksdio: Check function enabled before doing close Chris Lu
@ 2025-04-21 14:01 ` bluez.test.bot
2025-04-21 19:19 ` [PATCH v1 1/2] Bluetooth: btmtksdio: Check function enabled before doing close Luiz Augusto von Dentz
1 sibling, 0 replies; 7+ messages in thread
From: bluez.test.bot @ 2025-04-21 14:01 UTC (permalink / raw)
To: linux-bluetooth, chris.lu
[-- Attachment #1: Type: text/plain, Size: 2109 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=955282
---Test result---
Test Summary:
CheckPatch PENDING 0.37 seconds
GitLint PENDING 0.25 seconds
SubjectPrefix PASS 0.11 seconds
BuildKernel PASS 24.56 seconds
CheckAllWarning PASS 26.99 seconds
CheckSparse PASS 30.07 seconds
BuildKernel32 PASS 23.97 seconds
TestRunnerSetup PASS 462.27 seconds
TestRunner_l2cap-tester PASS 21.38 seconds
TestRunner_iso-tester PASS 30.72 seconds
TestRunner_bnep-tester PASS 4.61 seconds
TestRunner_mgmt-tester FAIL 119.29 seconds
TestRunner_rfcomm-tester PASS 7.73 seconds
TestRunner_sco-tester PASS 12.51 seconds
TestRunner_ioctl-tester PASS 8.17 seconds
TestRunner_mesh-tester PASS 5.91 seconds
TestRunner_smp-tester PASS 7.09 seconds
TestRunner_userchan-tester PASS 4.88 seconds
IncrementalBuild PENDING 0.85 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 483 (98.6%), Failed: 3, Not Run: 4
Failed Test Cases
LL Privacy - Add Device 2 (2 Devices to AL) Failed 0.166 seconds
LL Privacy - Add Device 3 (AL is full) Failed 0.193 seconds
LL Privacy - Set Flags 2 (Enable RL) Failed 0.146 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/2] Bluetooth: btmtksdio: Check function enabled before doing close
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 ` Luiz Augusto von Dentz
1 sibling, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2025-04-21 19:19 UTC (permalink / raw)
To: Chris Lu
Cc: Marcel Holtmann, Johan Hedberg, Sean Wang, Jiande Lu, Will Lee,
SS Wu, Steve Lee, linux-bluetooth, linux-kernel, linux-mediatek
Hi Chris,
On Mon, Apr 21, 2025 at 3:29 AM Chris Lu <chris.lu@mediatek.com> wrote:
>
> Check BTMTKSDIO_FUNC_ENABLED flag before doing close to prevent
> btmtksdio_close been called twice.
>
> Signed-off-by: Chris Lu <chris.lu@mediatek.com>
Please add Fixes tag.
> ---
> 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
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1 2/2] Bluetooth: btmtksdio: Do close if SDIO card removed without close
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 7:29 ` Chris Lu
2025-04-21 19:19 ` Luiz Augusto von Dentz
1 sibling, 1 reply; 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
To prevent Bluetooth SDIO card from being physically removed suddenly,
driver needs to ensure btmtksdio_close is called before btmtksdio_remove
to disable interrupts and txrx workqueue.
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] 7+ messages in thread
* Re: [PATCH v1 2/2] Bluetooth: btmtksdio: Do close if SDIO card removed without close
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
0 siblings, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2025-04-21 19:19 UTC (permalink / raw)
To: Chris Lu
Cc: Marcel Holtmann, Johan Hedberg, Sean Wang, Jiande Lu, Will Lee,
SS Wu, Steve Lee, linux-bluetooth, linux-kernel, linux-mediatek
Hi Chris,
On Mon, Apr 21, 2025 at 3:29 AM Chris Lu <chris.lu@mediatek.com> wrote:
>
> To prevent Bluetooth SDIO card from being physically removed suddenly,
> driver needs to ensure btmtksdio_close is called before btmtksdio_remove
> to disable interrupts and txrx workqueue.
>
> Signed-off-by: Chris Lu <chris.lu@mediatek.com>
Ditto, please add Fixes tag.
> ---
> 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
>
--
Luiz Augusto von Dentz
^ 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* RE: Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove
2025-04-22 1:21 [PATCH v2 1/2] Bluetooth: btmtksdio: Check function enabled before doing close Chris Lu
@ 2025-04-22 3:07 ` bluez.test.bot
0 siblings, 0 replies; 7+ messages in thread
From: bluez.test.bot @ 2025-04-22 3:07 UTC (permalink / raw)
To: linux-bluetooth, chris.lu
[-- Attachment #1: Type: text/plain, Size: 1949 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=955503
---Test result---
Test Summary:
CheckPatch PENDING 0.36 seconds
GitLint PENDING 0.32 seconds
SubjectPrefix PASS 0.13 seconds
BuildKernel PASS 25.68 seconds
CheckAllWarning PASS 28.15 seconds
CheckSparse PASS 31.70 seconds
BuildKernel32 PASS 25.29 seconds
TestRunnerSetup PASS 478.26 seconds
TestRunner_l2cap-tester PASS 21.72 seconds
TestRunner_iso-tester PASS 35.78 seconds
TestRunner_bnep-tester PASS 4.90 seconds
TestRunner_mgmt-tester FAIL 126.75 seconds
TestRunner_rfcomm-tester PASS 8.05 seconds
TestRunner_sco-tester PASS 12.70 seconds
TestRunner_ioctl-tester PASS 8.47 seconds
TestRunner_mesh-tester PASS 6.17 seconds
TestRunner_smp-tester PASS 7.40 seconds
TestRunner_userchan-tester PASS 5.05 seconds
IncrementalBuild PENDING 0.95 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 485 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
LL Privacy - Set Flags 1 (Add to RL) Failed 0.151 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [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