-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Deepin-Kernel-SIG] [Upstream] [linux 6.6-y] Sync some btmtk bugfix from mainline #606
base: linux-6.6.y
Are you sure you want to change the base?
[Deepin-Kernel-SIG] [Upstream] [linux 6.6-y] Sync some btmtk bugfix from mainline #606
Conversation
mainline inclusion from mainline-v6.13-rc1 category: bugfix Move MediaTek Bluetooth power off command before releasing usb ISO interface. Signed-off-by: Chris Lu <chris.lu@mediatek.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit ad0c6f603bb0b07846fda484c59a176a8cd02838)
mainline inclusion from mainline-v6.13-rc1 category: bugfix MediaTek claim an special usb intr interface for ISO data transmission. The interface need to be released before unregistering hci device when usb disconnect. Removing BT usb dongle without properly releasing the interface may cause Kernel panic while unregister hci device. Signed-off-by: Chris Lu <chris.lu@mediatek.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit 489304e67087abddc2666c5af0159cb95afdcf59)
mainline inclusion from mainline-v6.13-rc1 category: bugfix Change conditions for Bluetooth driver claiming and releasing usb ISO interface for MediaTek ISO data transmission. Signed-off-by: Chris Lu <chris.lu@mediatek.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit defc33b5541e0a7e45cc2d99d72fbe80a597afc5)
mainline inclusion from mainline-v6.13-rc1 category: bugfix MediaTek iso data anchor init should be moved to where MediaTek claims iso data interface. If there is an unexpected BT usb disconnect during setup flow, it will cause a NULL pointer crash issue when releasing iso anchor since the anchor wasn't been init yet. Adjust the position to do iso data anchor init. [ 17.137991] pc : usb_kill_anchored_urbs+0x60/0x168 [ 17.137998] lr : usb_kill_anchored_urbs+0x44/0x168 [ 17.137999] sp : ffffffc0890cb5f0 [ 17.138000] x29: ffffffc0890cb5f0 x28: ffffff80bb6c2e80 [ 17.144081] gpio gpiochip0: registered chardev handle for 1 lines [ 17.148421] x27: 0000000000000000 [ 17.148422] x26: ffffffd301ff4298 x25: 0000000000000003 x24: 00000000000000f0 [ 17.148424] x23: 0000000000000000 x22: 00000000ffffffff x21: 0000000000000001 [ 17.148425] x20: ffffffffffffffd8 x19: ffffff80c0f25560 x18: 0000000000000000 [ 17.148427] x17: ffffffd33864e408 x16: ffffffd33808f7c8 x15: 0000000000200000 [ 17.232789] x14: e0cd73cf80ffffff x13: 50f2137c0a0338c9 x12: 0000000000000001 [ 17.239912] x11: 0000000080150011 x10: 0000000000000002 x9 : 0000000000000001 [ 17.247035] x8 : 0000000000000000 x7 : 0000000000008080 x6 : 8080000000000000 [ 17.254158] x5 : ffffffd33808ebc0 x4 : fffffffe033dcf20 x3 : 0000000080150011 [ 17.261281] x2 : ffffff8087a91400 x1 : 0000000000000000 x0 : ffffff80c0f25588 [ 17.268404] Call trace: [ 17.270841] usb_kill_anchored_urbs+0x60/0x168 [ 17.275274] btusb_mtk_release_iso_intf+0x2c/0xd8 [btusb (HASH:5afe 6)] [ 17.284226] btusb_mtk_disconnect+0x14/0x28 [btusb (HASH:5afe 6)] [ 17.292652] btusb_disconnect+0x70/0x140 [btusb (HASH:5afe 6)] [ 17.300818] usb_unbind_interface+0xc4/0x240 [ 17.305079] device_release_driver_internal+0x18c/0x258 [ 17.310296] device_release_driver+0x1c/0x30 [ 17.314557] bus_remove_device+0x140/0x160 [ 17.318643] device_del+0x1c0/0x330 [ 17.322121] usb_disable_device+0x80/0x180 [ 17.326207] usb_disconnect+0xec/0x300 [ 17.329948] hub_quiesce+0x80/0xd0 [ 17.333339] hub_disconnect+0x44/0x190 [ 17.337078] usb_unbind_interface+0xc4/0x240 [ 17.341337] device_release_driver_internal+0x18c/0x258 [ 17.346551] device_release_driver+0x1c/0x30 [ 17.350810] usb_driver_release_interface+0x70/0x88 [ 17.355677] proc_ioctl+0x13c/0x228 [ 17.359157] proc_ioctl_default+0x50/0x80 [ 17.363155] usbdev_ioctl+0x830/0xd08 [ 17.366808] __arm64_sys_ioctl+0x94/0xd0 [ 17.370723] invoke_syscall+0x6c/0xf8 [ 17.374377] el0_svc_common+0x84/0xe0 [ 17.378030] do_el0_svc+0x20/0x30 [ 17.381334] el0_svc+0x34/0x60 [ 17.384382] el0t_64_sync_handler+0x88/0xf0 [ 17.388554] el0t_64_sync+0x180/0x188 [ 17.392208] Code: f9400677 f100a2f4 54fffea0 d503201f (b8350288) [ 17.398289] ---[ end trace 0000000000000000 ]--- Fixes: ceac1cb0259d ("Bluetooth: btusb: mediatek: add ISO data transmission functions") Signed-off-by: Chris Lu <chris.lu@mediatek.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit 61c5a3def90ac729a538e5ca5ff7f461cff72776)
mainline inclusion from mainline-v6.14-rc1 category: bugfix 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> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit e9087e828827e5a5c85e124ce77503f2b81c3491)
Reviewer's Guide by SourceryThis pull request synchronizes several bug fixes from the mainline kernel related to the MediaTek Bluetooth USB driver (btmtk). These fixes address issues related to claiming and releasing the ISO interface, handling USB disconnects, and power management. The changes involve adding locking, adjusting initialization order, modifying conditional checks, and implementing a disconnect flow. Sequence diagram for claiming the ISO interfacesequenceDiagram
participant btusb_mtk_claim_iso_intf
participant device_lock
participant usb_driver_claim_interface
participant device_unlock
participant set_bit
participant init_usb_anchor
btusb_mtk_claim_iso_intf->>device_lock: device_lock(&btmtk_data->isopkt_intf->dev)
activate device_lock
device_lock-->>btusb_mtk_claim_iso_intf:
deactivate device_lock
btusb_mtk_claim_iso_intf->>usb_driver_claim_interface: usb_driver_claim_interface(&btusb_driver, btmtk_data->isopkt_intf, data)
activate usb_driver_claim_interface
usb_driver_claim_interface-->>btusb_mtk_claim_iso_intf: err
deactivate usb_driver_claim_interface
alt err < 0
btusb_mtk_claim_iso_intf->>btusb_mtk_claim_iso_intf: btmtk_data->isopkt_intf = NULL
btusb_mtk_claim_iso_intf->>btusb_mtk_claim_iso_intf: bt_dev_err(data->hdev, "Failed to claim iso interface")
else err >= 0
btusb_mtk_claim_iso_intf->>set_bit: set_bit(BTMTK_ISOPKT_OVER_INTR, &btmtk_data->flags)
activate set_bit
set_bit-->>btusb_mtk_claim_iso_intf:
deactivate set_bit
btusb_mtk_claim_iso_intf->>init_usb_anchor: init_usb_anchor(&btmtk_data->isopkt_anchor)
activate init_usb_anchor
init_usb_anchor-->>btusb_mtk_claim_iso_intf:
deactivate init_usb_anchor
end
btusb_mtk_claim_iso_intf->>device_unlock: device_unlock(&btmtk_data->isopkt_intf->dev)
activate device_unlock
device_unlock-->>btusb_mtk_claim_iso_intf:
deactivate device_unlock
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @opsiff - I've reviewed your changes - here's some feedback:
Overall Comments:
- It looks like
btusb_mtk_release_iso_intf
now takesstruct hci_dev *hdev
instead ofstruct btusb_data *data
, but the commit message still refers todata
. - Consider adding a comment explaining why
btusb_mtk_disconnect
is needed.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sourcery-ai[bot] The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes:
commit 1d734a2: ("Bluetooth: btusb: mediatek: add ISO data transmission functions")
Commit:
Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface()
Bluetooth: btmtk: adjust the position to init iso data anchor
Bluetooth: btusb: mediatek: change the conditions for ISO interface
Bluetooth: btusb: mediatek: add intf release flow when usb disconnect
Bluetooth: btusb: mediatek: move Bluetooth power off command position
Summary by Sourcery
Fix several bugs related to the MediaTek Bluetooth USB driver, including a potential deadlock, incorrect interface handling, and ISO data transmission issues. Introduce a disconnect handler to release the ISO interface upon disconnection. Adjust the initialization timing of the ISO data anchor and the Bluetooth power off command.
Bug Fixes:
usb_driver_claim_interface()
when called outside of probe routines.