* [PATCH 1/2] Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface()
@ 2025-01-16 3:36 Douglas Anderson
2025-01-16 3:36 ` [PATCH 2/2] Bluetooth: btusb: mediatek: Add err code to btusb claim iso printout Douglas Anderson
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Douglas Anderson @ 2025-01-16 3:36 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: Douglas Anderson, AngeloGioacchino Del Regno, Chris Lu,
Matthias Brugger, linux-arm-kernel, linux-bluetooth, linux-kernel,
linux-mediatek
The documentation for usb_driver_claim_interface() says that "the
device lock" is needed when the function is called from places other
than probe(). This appears to be the lock for the USB interface
device. The Mediatek btusb code gets called via this path:
Workqueue: hci0 hci_power_on [bluetooth]
Call trace:
usb_driver_claim_interface
btusb_mtk_claim_iso_intf
btusb_mtk_setup
hci_dev_open_sync
hci_power_on
process_scheduled_works
worker_thread
kthread
With the above call trace the device lock hasn't been claimed. Claim
it.
Without this fix, we'd sometimes see the error "Failed to claim iso
interface". Sometimes we'd even see worse errors, like a NULL pointer
dereference (where `intf->dev.driver` was NULL) with a trace like:
Call trace:
usb_suspend_both
usb_runtime_suspend
__rpm_callback
rpm_suspend
pm_runtime_work
process_scheduled_works
Both errors appear to be fixed with the proper locking.
Fixes: ceac1cb0259d ("Bluetooth: btusb: mediatek: add ISO data transmission functions")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
drivers/bluetooth/btusb.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 279fe6c115fa..f69df515d668 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2638,8 +2638,15 @@ static void btusb_mtk_claim_iso_intf(struct btusb_data *data)
struct btmtk_data *btmtk_data = hci_get_priv(data->hdev);
int err;
+ /*
+ * The function usb_driver_claim_interface() is documented to need
+ * locks held if it's not called from a probe routine. The code here
+ * is called from the hci_power_on workqueue, so grab the lock.
+ */
+ device_lock(&btmtk_data->isopkt_intf->dev);
err = usb_driver_claim_interface(&btusb_driver,
btmtk_data->isopkt_intf, data);
+ device_unlock(&btmtk_data->isopkt_intf->dev);
if (err < 0) {
btmtk_data->isopkt_intf = NULL;
bt_dev_err(data->hdev, "Failed to claim iso interface");
--
2.48.0.rc2.279.g1de40edade-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] Bluetooth: btusb: mediatek: Add err code to btusb claim iso printout
2025-01-16 3:36 [PATCH 1/2] Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface() Douglas Anderson
@ 2025-01-16 3:36 ` Douglas Anderson
2025-01-16 3:56 ` [1/2] Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface() bluez.test.bot
2025-01-21 16:40 ` [PATCH 1/2] " patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: Douglas Anderson @ 2025-01-16 3:36 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: Douglas Anderson, AngeloGioacchino Del Regno, Matthias Brugger,
linux-arm-kernel, linux-bluetooth, linux-kernel, linux-mediatek
Add the error code to the message "Failed to claim iso
interface". That allows us to know which error case
usb_driver_claim_interface() hit.
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
drivers/bluetooth/btusb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index f69df515d668..df8889e8759b 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2649,7 +2649,7 @@ static void btusb_mtk_claim_iso_intf(struct btusb_data *data)
device_unlock(&btmtk_data->isopkt_intf->dev);
if (err < 0) {
btmtk_data->isopkt_intf = NULL;
- bt_dev_err(data->hdev, "Failed to claim iso interface");
+ bt_dev_err(data->hdev, "Failed to claim iso interface: %d", err);
return;
}
--
2.48.0.rc2.279.g1de40edade-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [1/2] Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface()
2025-01-16 3:36 [PATCH 1/2] Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface() Douglas Anderson
2025-01-16 3:36 ` [PATCH 2/2] Bluetooth: btusb: mediatek: Add err code to btusb claim iso printout Douglas Anderson
@ 2025-01-16 3:56 ` bluez.test.bot
2025-01-21 16:40 ` [PATCH 1/2] " patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2025-01-16 3:56 UTC (permalink / raw)
To: linux-bluetooth, dianders
[-- Attachment #1: Type: text/plain, Size: 2434 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=925915
---Test result---
Test Summary:
CheckPatch PENDING 0.30 seconds
GitLint PENDING 0.28 seconds
SubjectPrefix PASS 0.12 seconds
BuildKernel PASS 24.65 seconds
CheckAllWarning PASS 26.88 seconds
CheckSparse PASS 30.75 seconds
BuildKernel32 PASS 24.37 seconds
TestRunnerSetup PASS 432.82 seconds
TestRunner_l2cap-tester PASS 20.52 seconds
TestRunner_iso-tester PASS 28.01 seconds
TestRunner_bnep-tester PASS 4.85 seconds
TestRunner_mgmt-tester FAIL 123.75 seconds
TestRunner_rfcomm-tester PASS 7.54 seconds
TestRunner_sco-tester PASS 9.29 seconds
TestRunner_ioctl-tester PASS 8.11 seconds
TestRunner_mesh-tester FAIL 6.27 seconds
TestRunner_smp-tester PASS 6.96 seconds
TestRunner_userchan-tester PASS 5.23 seconds
IncrementalBuild PENDING 0.74 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: 484 (98.8%), Failed: 2, Not Run: 4
Failed Test Cases
LL Privacy - Add Device 3 (AL is full) Failed 0.210 seconds
LL Privacy - Set Flags 2 (Enable RL) Failed 0.146 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
BUG: KASAN: slab-use-after-free in run_timer_softirq+0x76f/0x7d0
WARNING: CPU: 0 PID: 34 at kernel/workqueue.c:2257 __queue_work+0x687/0xb40
Total: 10, Passed: 9 (90.0%), Failed: 1, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Failed 0.110 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface()
2025-01-16 3:36 [PATCH 1/2] Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface() Douglas Anderson
2025-01-16 3:36 ` [PATCH 2/2] Bluetooth: btusb: mediatek: Add err code to btusb claim iso printout Douglas Anderson
2025-01-16 3:56 ` [1/2] Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface() bluez.test.bot
@ 2025-01-21 16:40 ` patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2025-01-21 16:40 UTC (permalink / raw)
To: Doug Anderson
Cc: marcel, luiz.dentz, angelogioacchino.delregno, chris.lu,
matthias.bgg, linux-arm-kernel, 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 Wed, 15 Jan 2025 19:36:36 -0800 you wrote:
> The documentation for usb_driver_claim_interface() says that "the
> device lock" is needed when the function is called from places other
> than probe(). This appears to be the lock for the USB interface
> device. The Mediatek btusb code gets called via this path:
>
> Workqueue: hci0 hci_power_on [bluetooth]
> Call trace:
> usb_driver_claim_interface
> btusb_mtk_claim_iso_intf
> btusb_mtk_setup
> hci_dev_open_sync
> hci_power_on
> process_scheduled_works
> worker_thread
> kthread
>
> [...]
Here is the summary with links:
- [1/2] Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface()
https://git.kernel.org/bluetooth/bluetooth-next/c/ec5570088c6a
- [2/2] Bluetooth: btusb: mediatek: Add err code to btusb claim iso printout
https://git.kernel.org/bluetooth/bluetooth-next/c/6ca1c15fcb92
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
end of thread, other threads:[~2025-01-21 16:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-16 3:36 [PATCH 1/2] Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface() Douglas Anderson
2025-01-16 3:36 ` [PATCH 2/2] Bluetooth: btusb: mediatek: Add err code to btusb claim iso printout Douglas Anderson
2025-01-16 3:56 ` [1/2] Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface() bluez.test.bot
2025-01-21 16:40 ` [PATCH 1/2] " patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).