Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove
Subsystems (2)
cover Bluetooth: btmtksdio: ensure btmtksdio_close is executed before btmtksdio_remove
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(-)
Signature · 1 line
2.45.2
PATCH 1/2 Bluetooth: btmtksdio: Check function enabled before doing close
Check BTMTKSDIO_FUNC_ENABLED flag before doing close to prevent btmtksdio_close been called twice.
--- drivers/bluetooth/btmtksdio.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/bluetooth/btmtksdio.c +4 -0
@@ -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 */
Signature · 1 line
2.45.2
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
Luiz Augusto von Dentz
maintainerRe: [PATCH v1 1/2] Bluetooth: btmtksdio: Check function enabled before doing close
In reply to Chris LuHi Chris,
Quoted 5 lines · Chris Lu
Check
BTMTKSDIO_FUNC_ENABLEDflag before doing close to preventbtmtksdio_closebeen called twice.Signed-off-by Chris Lu <[email protected]>
Please add Fixes tag.
Quoted 22 lines
--- drivers/bluetooth/btmtksdio.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/bluetooth/btmtksdio.c +4
-1@@ -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
Signature · 1 line
Luiz Augusto von Dentz
PATCH 2/2 Bluetooth: btmtksdio: Do close if SDIO card removed without close
In reply to Chris LuTo 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.
--- drivers/bluetooth/btmtksdio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/bluetooth/btmtksdio.c +6 -2
@@ -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);
Signature · 1 line
2.45.2
Luiz Augusto von Dentz
maintainerRe: [PATCH v1 2/2] Bluetooth: btmtksdio: Do close if SDIO card removed without close
Hi Chris,
Quoted 6 lines · Chris Lu
To prevent Bluetooth SDIO card from being physically removed suddenly, driver needs to ensure
btmtksdio_closeis called beforebtmtksdio_removeto disable interrupts and txrx workqueue.Signed-off-by Chris Lu <[email protected]>
Ditto, please add Fixes tag.
Quoted 29 lines
--- drivers/bluetooth/btmtksdio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/bluetooth/btmtksdio.c +6
-3@@ -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
Signature · 1 line
Luiz Augusto von Dentz