Repository navigation
Bluetooth: bcm4388: fix Read Local Supported Codecs v2 layout and -EINVAL caps - #3607
Conversation
…yout BCM4388 firmware encodes HCI_OP_READ_LOCAL_CODECS_V2 (0x100d) return parameters as separate ID and transport arrays rather than the Bluetooth Core Spec interleaved (id, transport) pairs and (cid, vid, transport) tuples. On a MacBook Pro M2 Max (J416), BCM4388 returns: 00 07 00 01 02 03 04 05 06 02 02 02 02 02 02 04 01 75 00 10 00 02 hci_read_supported_codecs_v2() parses those bytes as seven interleaved pairs, generating bogus codec/transport probes (10 failing Read Local Codec Capabilities commands) and missing LC3 (id 0x06, LE CIS transport 0x04), whose capabilities BCM4388 does return when queried properly. Add a broken_codecs_v2_layout quirk for BCM4388 and re-interleave successful HCI_OP_READ_LOCAL_CODECS_V2 command-complete replies in place before passing them to hci_recv_frame(). Signed-off-by: Marcelo Alcantara <[email protected]>
Some controllers (including Apple/Broadcom BCM4388) advertise HCI_OP_READ_LOCAL_CODEC_CAPS (0x100e) and return capabilities for LE ISO codecs such as LC3, while rejecting Read Local Codec Capabilities with HCI_ERROR_INVALID_PARAMETERS (-EINVAL) for BR/EDR SCO codecs that have no capabilities rather than returning num_caps = 0. When __hci_cmd_sync_sk(HCI_OP_READ_LOCAL_CODEC_CAPS) returns -EINVAL, log at debug level and still register the codec in hdev->local_codecs without capabilities, matching the existing fallback when the command is unsupported. Preserve bt_dev_err() for transport and timeout errors. Signed-off-by: Marcelo Alcantara <[email protected]>
Add KUnit coverage for bcm4377_fixup_codecs_v2() covering a live BCM4388 Read Local Supported Codecs v2 capture, multi-vendor re-interleaving, non-zero status, unrelated opcodes, truncated buffers, and empty codec lists. Signed-off-by: Marcelo Alcantara <[email protected]>
There was a problem hiding this comment.
Verdict: MERGE at 40936f13
Blockers: none (await queued CI completion before merge).
Checked:
- Audited all 3 commits across
drivers/bluetooth/hci_bcm4377.c,drivers/bluetooth/hci_bcm4377_test.c,net/bluetooth/hci_codec.c, andinclude/net/bluetooth/hci.h. bcm4377_fixup_codecs_v2()is gated solely on BCM4388 (broken_codecs_v2_layout) on linearHCI_EVENT_PKTskbs and bounds-checksskb->len,hdr->evt,hdr->plen,cc->opcode,rp[0] == 0,3 + std_len, and3 + std_len + vnd_len. Becausehdr->plen <= 255,rp_len <= 252, bounding bothstd_lenandvnd_lento<= 249 < sizeof(tmp)(U8_MAX = 255) with packedsizeof(struct hci_std_codec_v2) == 2andsizeof(struct hci_vnd_codec_v2) == 5.net/bluetooth/hci_codec.ctreats-EINVALfromHCI_OP_READ_LOCAL_CODEC_CAPSas empty capabilities (bt_dev_dbg()+hci_codec_list_add(&hdev->local_codecs, cmd, NULL, NULL, 0)underhci_dev_lock), matching the existing unsupported-command path and preservingbt_dev_err()for transport/timeout errors.hci_bcm4377_test.c(included at the tail ofhci_bcm4377.cunderCONFIG_BT_HCIBCM4377_KUNIT_TEST) adds KUnit coverage for the live J416 BCM4388 capture, multi-vendor re-interleaving, error status, other opcodes, truncated buffers, and empty lists.- J416 (M2 Max, BCM4388) hardware verification eliminates all 10
Failed to read codec capabilities (-22)errors, recovers spec-interleaved0x100doutput including LC3 (0x06, transport0x04), and passesboot-healthandomarchy-m-test. - DCO
Signed-off-by:present on all 3 commits; no Apple material or policy issues.
Evidence
- Diff:
drivers/bluetooth/hci_bcm4377.c,drivers/bluetooth/hci_bcm4377_test.c,net/bluetooth/hci_codec.c(+196/-2). - Verified
hci_codec_list_add()checksif (rp)before touchingrp->num_capsorcaps. - CI at review time: 3 queued, 1 pending, 1 skipped (
0failures).
Carry four Omarchy 4.6 RC kernel fixes for J416 / Apple Silicon 7.3 until upstream merges and retires them: - aurora-silicon/linux#3605 (222e0e6): downgrade repeated ACIO Phase 3 AT register read timeout RTKit syslogs to dev_dbg() - aurora-silicon/linux#3606 (4551c62): bind ane_t6021 quietly when firmware is absent so the 7 PMGR domains reach sync_state() - aurora-silicon/linux#3607 (40936f1, runtime commits 21bf1ba and aa3002f): fix BCM4388 codecs_v2 SoA layout and -EINVAL SCO caps - aurora-silicon/linux#3608 (8783076): honor fault_log_ratelimit() in asahi mark_pending_events() All five carried commits cherry-pick cleanly onto carry/aurora-7.3 (3058cc5) with zero conflicts and passed hardware verification on m2-max (lab build b1129-174341-04de, jobs j1129-174818-e436 and j1129-175551-7b35). Signed-off-by: Marcelo Alcantara <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
J416c (16-inch M2 Max, T6021) at EvidenceBatched carry kernel
|
|
Merging at |
What: Fix the 10x
Bluetooth: hci0: Failed to read codec capabilities (-22)boot errors on Apple/Broadcom BCM4388 and recover LC3 capability enumeration:hci_bcm4377: Add abroken_codecs_v2_layoutquirk onBCM4388that re-interleaves successfulHCI_OP_READ_LOCAL_CODECS_V2(0x100d) command-complete replies in place from BCM4388's separate ID/transport arrays into the Bluetooth Core Spec interleaved(id, transport)/(cid, vid, transport)layout.hci_codec: WhenHCI_OP_READ_LOCAL_CODEC_CAPS(0x100e) returns-EINVAL(HCI_ERROR_INVALID_PARAMETERS, which BCM4388 returns for BR/EDR SCO codecs without capabilities), log at debug level and register the codec inhdev->local_codecswith zero capabilities instead of loggingbt_dev_err().hci_bcm4377_test: Add KUnit tests forbcm4377_fixup_codecs_v2()using a live J416 BCM4388 capture plus multi-vendor and malformed-packet edge cases.Tested: J416 (MacBook Pro 16" M2 Max, BCM4388) on 7.3 carry build
7.3.0-lab3ceda392-11ed(lab jobsj1129-174818-e436andj1129-175551-7b35,b1129-174341-04de, clang 19.1.7 + lld):7.3.0-1-1-ARCH): 10xBluetooth: hci0: Failed to read codec capabilities (-22)on every boot; raw HCI0x100dreturned SoA bytes00 07 00 01 02 03 04 05 06 02 02 02 02 02 02 04 01 75 00 10 00 02(missing LC3).7.3.0-lab3ceda392-11ed): 0Failed to read codec capabilitieserrors,hci0present and powered (btmgmt info), and live raw HCI0x100dreply matches exact spec interleaved AoS layout00 07 00 02 01 02 02 02 03 02 04 02 05 02 06 04 01 75 00 10 00 02(including LC3id=0x06, tr=0x04).boot-healthpass (0 failed units, 0 kernel errors on clean bootj1129-174818-e436),omarchy-m-test 0.2.0pass (0 regressions);checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks on all 3 commits.Risk: two-way door · layout fixup is gated on
BCM4388and bounds-checked againstskb->lenandhdr->plen;hci_codeckeepsbt_dev_err()for transport/timeout errors and only treats-EINVALas empty codec capabilities.