[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] Sync bluetooth fixes from mainline - #2033
Conversation
mainline inclusion from mainline-v6.11-rc1 category: bugfix Fixes: f3b845e ("Bluetooth: btintel: Add support to download intermediate loader") Cc: Kiran K <kiran.k@intel.com> Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit 519d849) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.14-rc3
category: bugfix
On HCI_OP_RESET command, firmware raises alive interrupt. Driver needs
to wait for this before sending other command. This patch fixes the potential
miss of alive interrupt due to which HCI_OP_RESET can timeout.
Expected flow:
If tx command is HCI_OP_RESET,
1. set data->gp0_received = false
2. send HCI_OP_RESET
3. wait for alive interrupt
Actual flow having potential race:
If tx command is HCI_OP_RESET,
1. send HCI_OP_RESET
1a. Firmware raises alive interrupt here and in ISR
data->gp0_received is set to true
2. set data->gp0_received = false
3. wait for alive interrupt
Signed-off-by: Kiran K <kiran.k@intel.com>
Fixes: 05c200c ("Bluetooth: btintel_pcie: Add handshake between driver and firmware")
Reported-by: Bjorn Helgaas <helgaas@kernel.org>
Closes: https://patchwork.kernel.org/project/bluetooth/patch/20241001104451.626964-1-kiran.k@intel.com/
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
(cherry picked from commit 872274b)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion from mainline-v6.15-rc5 category: bugfix Reuse the skb buffer provided by the PCIe driver to pass it onto the stack, instead of copying it to a new skb. Fixes: c2b636b ("Bluetooth: btintel_pcie: Add support for PCIe transport") Signed-off-by: Kiran K <kiran.k@intel.com> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit d1af1f0) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion from mainline-v6.15-rc5 category: bugfix Due to a hardware issue, there is a possibility that the driver may miss an MSIx interrupt on the RX/TX data path. Since the TX and RX paths are independent, when a TX MSIx interrupt occurs, the driver can check the RX queue for any pending data and process it if present. The same approach applies to the RX path. Fixes: c2b636b ("Bluetooth: btintel_pcie: Add support for PCIe transport") Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> Signed-off-by: Kiran K <kiran.k@intel.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit 1c76649) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion from mainline-v6.16-rc1 category: bugfix Since the size of struct btintel_dsbr is already known, we can just start there instead of querying the EFI variable size. If the final result doesn't match what we expect also fail. This fixes a stack buffer overflow when the EFI variable is larger than struct btintel_dsbr. Reported-by: zepta <z3ptaa@gmail.com> Closes: https://lore.kernel.org/all/CAPBS6KoaWV9=dtjTESZiU6KK__OZX0KpDk-=JEH8jCHFLUYv3Q@mail.gmail.com Fixes: eb9e749 ("Bluetooth: btintel: Allow configuring drive strength of BRI") Signed-off-by: Kees Cook <kees@kernel.org> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit 3aa1dc3) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion from mainline-v6.16-rc2 category: bugfix The driver was posting only 6 rx buffers, despite the maximum rx buffers being defined as 16. Having fewer RX buffers caused firmware exceptions in HID use cases when events arrived in bursts. Exception seen on android 6.12 kernel. E Bluetooth: hci0: Received hw exception interrupt E Bluetooth: hci0: Received gp1 mailbox interrupt D Bluetooth: hci0: 00000000: ff 3e 87 80 03 01 01 01 03 01 0c 0d 02 1c 10 0e D Bluetooth: hci0: 00000010: 01 00 05 14 66 b0 28 b0 c0 b0 28 b0 ac af 28 b0 D Bluetooth: hci0: 00000020: 14 f1 28 b0 00 00 00 00 fa 04 00 00 00 00 40 10 D Bluetooth: hci0: 00000030: 08 00 00 00 7a 7a 7a 7a 47 00 fb a0 10 00 00 00 D Bluetooth: hci0: 00000000: 10 01 0a E Bluetooth: hci0: ---- Dump of debug registers — E Bluetooth: hci0: boot stage: 0xe0fb0047 E Bluetooth: hci0: ipc status: 0x00000004 E Bluetooth: hci0: ipc control: 0x00000000 E Bluetooth: hci0: ipc sleep control: 0x00000000 E Bluetooth: hci0: mbox_1: 0x00badbad E Bluetooth: hci0: mbox_2: 0x0000101c E Bluetooth: hci0: mbox_3: 0x00000008 E Bluetooth: hci0: mbox_4: 0x7a7a7a7a Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> Signed-off-by: Kiran K <kiran.k@intel.com> Fixes: c2b636b ("Bluetooth: btintel_pcie: Add support for PCIe transport") Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit daabd27) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion from mainline-v6.16-rc2 category: bugfix This change addresses latency issues observed in HID use cases where events arrive in bursts. By increasing the Rx descriptor count to 64, the firmware can handle bursty data more effectively, reducing latency and preventing buffer overflows. Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> Signed-off-by: Kiran K <kiran.k@intel.com> Fixes: c2b636b ("Bluetooth: btintel_pcie: Add support for PCIe transport") Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit 2dd7111) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
… condition mainline inclusion from mainline-v6.16-rc2 category: bugfix Modify the driver to post 3 fewer buffers than the maximum rx buffers (64) allowed for the firmware. This change mitigates a hardware issue causing a race condition in the firmware, improving stability and data handling. Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> Signed-off-by: Kiran K <kiran.k@intel.com> Fixes: c2b636b ("Bluetooth: btintel_pcie: Add support for PCIe transport") Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit bf2ffc4) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Reviewer's GuideSynchronizes multiple Bluetooth driver fixes from mainline, focusing on Intel PCIe, USB Mediatek, Intel EFI handling, and HCI core cleanups, with queue sizing, interrupt handling, memory management, and robustness improvements. Sequence diagram for updated Intel PCIe interrupt and alive handlingsequenceDiagram
actor HostCPU
participant btintel_pcie_send_frame
participant gp0_wait_q
participant btintel_pcie_irq_msix_handler
participant btintel_pcie_msix_gp0_handler
participant btintel_pcie_msix_tx_handle
participant btintel_pcie_msix_rx_handle
participant btintel_pcie_is_rxq_empty
participant btintel_pcie_is_txackq_empty
HostCPU->>btintel_pcie_send_frame: hci_dev_queue_skb
btintel_pcie_send_frame->>btintel_pcie_send_frame: set data.gp0_received = false on HCI_OP_RESET or BTINTEL_HCI_OP_RESET
btintel_pcie_send_frame->>gp0_wait_q: wait_event_timeout(gp0_wait_q, gp0_received)
Note over btintel_pcie_irq_msix_handler,btintel_pcie_msix_gp0_handler: Alive interrupt path
HostCPU-->>btintel_pcie_irq_msix_handler: MSIX interrupt
btintel_pcie_irq_msix_handler->>btintel_pcie_msix_gp0_handler: btintel_pcie_msix_gp0_handler
btintel_pcie_msix_gp0_handler->>gp0_wait_q: wake_up on alive interrupt (gp0_received = true)
alt intr_fh has BTINTEL_PCIE_MSIX_FH_INT_CAUSES_0
btintel_pcie_irq_msix_handler->>btintel_pcie_msix_tx_handle: btintel_pcie_msix_tx_handle
btintel_pcie_irq_msix_handler->>btintel_pcie_is_rxq_empty: btintel_pcie_is_rxq_empty
btintel_pcie_is_rxq_empty-->>btintel_pcie_irq_msix_handler: false when RXQ has entries
btintel_pcie_irq_msix_handler->>btintel_pcie_msix_rx_handle: btintel_pcie_msix_rx_handle when RXQ not empty
end
alt intr_fh has BTINTEL_PCIE_MSIX_FH_INT_CAUSES_1
btintel_pcie_irq_msix_handler->>btintel_pcie_msix_rx_handle: btintel_pcie_msix_rx_handle
btintel_pcie_irq_msix_handler->>btintel_pcie_is_txackq_empty: btintel_pcie_is_txackq_empty
btintel_pcie_is_txackq_empty-->>btintel_pcie_irq_msix_handler: false when TXACKQ has entries
btintel_pcie_irq_msix_handler->>btintel_pcie_msix_tx_handle: btintel_pcie_msix_tx_handle when TXACKQ not empty
end
gp0_wait_q-->>btintel_pcie_send_frame: wakeup when gp0_received
btintel_pcie_send_frame-->>HostCPU: return or timeout with err_tx increment
Flow diagram for Mediatek ISO interface claim and releaseflowchart TD
A[btusb_mtk_claim_iso_intf] --> B{data.hdev is NULL?}
B -->|yes| Z[return]
B -->|no| C[hci_get_priv]
C --> D{btmtk_data is NULL?}
D -->|yes| Z
D -->|no| E{btmtk_data.isopkt_intf is NULL?}
E -->|yes| F[bt_dev_err Can't claim NULL iso interface; return]
E -->|no| G[usb_driver_claim_interface]
subgraph ReleasePath
R[btusb_mtk_release_iso_intf] --> S{hdev is NULL?}
S -->|yes| Z2[return]
S -->|no| T[hci_get_priv]
T --> U{btmtk_data is NULL?}
U -->|yes| Z2
U -->|no| V{BTMTK_ISOPKT_OVER_INTR set?}
V -->|no| W[clear BTMTK_ISOPKT_OVER_INTR]
V -->|yes| X[usb_kill_anchored_urbs; clear BTMTK_ISOPKT_RUNNING]
X --> Y{btmtk_data.isopkt_skb is non-NULL?}
Y -->|yes| Y1[dev_kfree_skb_irq; set isopkt_skb NULL]
Y -->|no| Y2[skip skb free]
X --> AA{btmtk_data.isopkt_intf is non-NULL?}
AA -->|yes| AB[usb_set_intfdata NULL; usb_driver_release_interface; set isopkt_intf NULL]
AA -->|no| AC[skip interface release]
AB --> W
AC --> W
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In btintel_pcie_start_rx(), consider replacing the hard-coded
rxq->count - 3offset with a named constant or macro that documents the hardware quirk, so future descriptor count changes don’t silently alter this behavior. - Now that btintel_pcie_irq_msix_handler conditionally calls both RX and TX handlers based on queue emptiness, it may be worth adding a brief comment near the helper functions explaining the expected ordering and why cross-calling is needed, to aid future maintainers in understanding the interrupt flow.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In btintel_pcie_start_rx(), consider replacing the hard-coded `rxq->count - 3` offset with a named constant or macro that documents the hardware quirk, so future descriptor count changes don’t silently alter this behavior.
- Now that btintel_pcie_irq_msix_handler conditionally calls both RX and TX handlers based on queue emptiness, it may be worth adding a brief comment near the helper functions explaining the expected ordering and why cross-calling is needed, to aid future maintainers in understanding the interrupt flow.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
This PR backports a set of upstream Bluetooth fixes to the 6.6.y kernel series, primarily targeting Intel PCIe controller stability/IRQ handling and MediaTek USB robustness, plus minor EFI handling and cleanup in core structures.
Changes:
- Intel PCIe: adjust RX/TX descriptor sizing, IRQ handling (threaded-only), RX processing, and alive-interrupt sequencing/diagnostics.
- MediaTek USB: harden isochronous interface claim/release paths and fix an URB leak on error.
- Core/EFI: remove unused
hci_conn::remote_id, tighten Intel EFI DSBR variable retrieval, and fix a comment typo.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| include/net/bluetooth/hci_core.h | Removes unused remote_id from struct hci_conn. |
| drivers/bluetooth/btusb.c | Adds NULL-safety around MediaTek ISO interface claim/release and frees resources defensively. |
| drivers/bluetooth/btmtk.c | Fixes URB leak on isochronous padding failure. |
| drivers/bluetooth/btintel.c | Makes EFI DSBR retrieval use fixed-size buffer and validates returned length; fixes comment typo. |
| drivers/bluetooth/btintel_pcie.h | Splits RX/TX descriptor counts and removes obsolete RX queue constant. |
| drivers/bluetooth/btintel_pcie.c | Updates RX posting strategy, IRQ handler behavior, diag event routing, skb reuse on RX, and alive-interrupt waiting. |
Suppressed comments (1)
drivers/bluetooth/btintel_pcie.c:820
- This return statement exceeds typical kernel line-length limits and will likely trigger checkpatch warnings; split the comparison across lines for readability.
static inline bool btintel_pcie_is_txackq_empty(struct btintel_pcie_data *data)
{
return data->ia.cr_tia[BTINTEL_PCIE_TXQ_NUM] == data->ia.cr_hia[BTINTEL_PCIE_TXQ_NUM];
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /* Firmware raises alive interrupt on HCI_OP_RESET or | ||
| * BTINTEL_HCI_OP_RESET | ||
| */ | ||
| if (opcode == HCI_OP_RESET || opcode == BTINTEL_HCI_OP_RESET) | ||
| data->gp0_received = false; |
| static inline bool btintel_pcie_is_rxq_empty(struct btintel_pcie_data *data) | ||
| { | ||
| return IRQ_WAKE_THREAD; | ||
| return data->ia.cr_hia[BTINTEL_PCIE_RXQ_NUM] == data->ia.cr_tia[BTINTEL_PCIE_RXQ_NUM]; | ||
| } |
…nterface mainline inclusion from mainline-v6.18 category: bugfix When performing reset tests and encountering abnormal card drop issues that lead to a kernel crash, it is necessary to perform a null check before releasing resources to avoid attempting to release a null pointer. <4>[ 29.158070] Hardware name: Google Quigon sku196612/196613 board (DT) <4>[ 29.158076] Workqueue: hci0 hci_cmd_sync_work [bluetooth] <4>[ 29.158154] pstate: 20400009 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) <4>[ 29.158162] pc : klist_remove+0x90/0x158 <4>[ 29.158174] lr : klist_remove+0x88/0x158 <4>[ 29.158180] sp : ffffffc0846b3c00 <4>[ 29.158185] pmr_save: 000000e0 <4>[ 29.158188] x29: ffffffc0846b3c30 x28: ffffff80cd31f880 x27: ffffff80c1bdc058 <4>[ 29.158199] x26: dead000000000100 x25: ffffffdbdc624ea3 x24: ffffff80c1bdc4c0 <4>[ 29.158209] x23: ffffffdbdc62a3e6 x22: ffffff80c6c07000 x21: ffffffdbdc829290 <4>[ 29.158219] x20: 0000000000000000 x19: ffffff80cd3e0648 x18: 000000031ec97781 <4>[ 29.158229] x17: ffffff80c1bdc4a8 x16: ffffffdc10576548 x15: ffffff80c1180428 <4>[ 29.158238] x14: 0000000000000000 x13: 000000000000e380 x12: 0000000000000018 <4>[ 29.158248] x11: ffffff80c2a7fd10 x10: 0000000000000000 x9 : 0000000100000000 <4>[ 29.158257] x8 : 0000000000000000 x7 : 7f7f7f7f7f7f7f7f x6 : 2d7223ff6364626d <4>[ 29.158266] x5 : 0000008000000000 x4 : 0000000000000020 x3 : 2e7325006465636e <4>[ 29.158275] x2 : ffffffdc11afeff8 x1 : 0000000000000000 x0 : ffffffdc11be4d0c <4>[ 29.158285] Call trace: <4>[ 29.158290] klist_remove+0x90/0x158 <4>[ 29.158298] device_release_driver_internal+0x20c/0x268 <4>[ 29.158308] device_release_driver+0x1c/0x30 <4>[ 29.158316] usb_driver_release_interface+0x70/0x88 <4>[ 29.158325] btusb_mtk_release_iso_intf+0x68/0xd8 [btusb (HASH:e8b6 5)] <4>[ 29.158347] btusb_mtk_reset+0x5c/0x480 [btusb (HASH:e8b6 5)] <4>[ 29.158361] hci_cmd_sync_work+0x10c/0x188 [bluetooth (HASH:a4fa 6)] <4>[ 29.158430] process_scheduled_works+0x258/0x4e8 <4>[ 29.158441] worker_thread+0x300/0x428 <4>[ 29.158448] kthread+0x108/0x1d0 <4>[ 29.158455] ret_from_fork+0x10/0x20 <0>[ 29.158467] Code: 91343000 940139d1 f9400268 927ff914 (f9401297) <4>[ 29.158474] ---[ end trace 0000000000000000 ]--- <0>[ 29.167129] Kernel panic - not syncing: Oops: Fatal exception <2>[ 29.167144] SMP: stopping secondary CPUs <4>[ 29.167158] ------------[ cut here ]------------ Fixes: ceac1cb ("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 4015b97) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion from mainline-v6.18 category: bugfix In btusb_mtk_setup(), we set `btmtk_data->isopkt_intf` to: usb_ifnum_to_if(data->udev, MTK_ISO_IFNUM) That function can return NULL in some cases. Even when it returns NULL, though, we still go on to call btusb_mtk_claim_iso_intf(). As of commit e9087e8 ("Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface()"), calling btusb_mtk_claim_iso_intf() when `btmtk_data->isopkt_intf` is NULL will cause a crash because we'll end up passing a bad pointer to device_lock(). Prior to that commit we'd pass the NULL pointer directly to usb_driver_claim_interface() which would detect it and return an error, which was handled. Resolve the crash in btusb_mtk_claim_iso_intf() by adding a NULL check at the start of the function. This makes the code handle a NULL `btmtk_data->isopkt_intf` the same way it did before the problematic commit (just with a slight change to the error message printed). Reported-by: IncogCyberpunk <incogcyberpunk@proton.me> Closes: http://lore.kernel.org/r/a380d061-479e-4713-bddd-1d6571ca7e86@leemhuis.info Fixes: e9087e8 ("Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface()") Cc: stable@vger.kernel.org Tested-by: IncogCyberpunk <incogcyberpunk@proton.me> Signed-off-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit c884a0b) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion from mainline-v7.0-rc1 category: bugfix There is no added value in btintel_pcie_msix_isr() compared to irq_default_primary_handler(). Using a threaded interrupt without a dedicated primary handler mandates the IRQF_ONESHOT flag to mask the interrupt source while the threaded handler is active. Otherwise the interrupt can fire again before the threaded handler had a chance to run. Use the default primary interrupt handler by specifying NULL and set IRQF_ONESHOT so the interrupt source is masked until the secondary handler is done. Fixes: c2b636b ("Bluetooth: btintel_pcie: Add support for PCIe transport") Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Link: https://patch.msgid.link/20260128095540.863589-7-bigeasy@linutronix.de (cherry picked from commit 28abed6) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion from mainline-v7.2-rc1 category: bugfix When btmtk_isopkt_pad() fails, the previously allocated URB is not freed, leaking the urb structure. Add usb_free_urb() before returning the error. Fixes: ceac1cb ("Bluetooth: btusb: mediatek: add ISO data transmission functions") Signed-off-by: Zhao Dongdong <zhaodongdong@kylinos.cn> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit f396f40) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
758eed5 to
f71eca2
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (2)
drivers/bluetooth/btintel_pcie.c:813
- These inline helpers exceed typical kernel line-length limits; please wrap the long return expression for readability and to avoid checkpatch warnings.
static inline bool btintel_pcie_is_rxq_empty(struct btintel_pcie_data *data)
{
return data->ia.cr_hia[BTINTEL_PCIE_RXQ_NUM] == data->ia.cr_tia[BTINTEL_PCIE_RXQ_NUM];
}
drivers/bluetooth/btintel_pcie.c:818
- This return statement is long enough to trip kernel style/line-length checks; please wrap it onto multiple lines for readability.
static inline bool btintel_pcie_is_txackq_empty(struct btintel_pcie_data *data)
{
return data->ia.cr_tia[BTINTEL_PCIE_TXQ_NUM] == data->ia.cr_hia[BTINTEL_PCIE_TXQ_NUM];
}
Summary by Sourcery
Sync various upstream Bluetooth driver fixes improving Intel PCIe, USB Mediatek, and EFI handling for stability and correctness.
Bug Fixes:
Enhancements: