Skip to content

Bluetooth: bcm4388: fix Read Local Supported Codecs v2 layout and -EINVAL caps - #3607

Merged
RyanTheTide merged 3 commits into
mainfrom
fix/bcm4388-codecs-v2
Dec 1, 2026
Merged

RyanTheTide merged 3 commits into
mainfrom
fix/bcm4388-codecs-v2

Conversation

@maralcbr

@maralcbr maralcbr commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What: Fix the 10x Bluetooth: hci0: Failed to read codec capabilities (-22) boot errors on Apple/Broadcom BCM4388 and recover LC3 capability enumeration:

  1. hci_bcm4377: Add a broken_codecs_v2_layout quirk on BCM4388 that re-interleaves successful HCI_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.
  2. hci_codec: When HCI_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 in hdev->local_codecs with zero capabilities instead of logging bt_dev_err().
  3. hci_bcm4377_test: Add KUnit tests for bcm4377_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 jobs j1129-174818-e436 and j1129-175551-7b35, b1129-174341-04de, clang 19.1.7 + lld):

  • Before (7.3.0-1-1-ARCH): 10x Bluetooth: hci0: Failed to read codec capabilities (-22) on every boot; raw HCI 0x100d returned SoA bytes 00 07 00 01 02 03 04 05 06 02 02 02 02 02 02 04 01 75 00 10 00 02 (missing LC3).
  • After (7.3.0-lab3ceda392-11ed): 0 Failed to read codec capabilities errors, hci0 present and powered (btmgmt info), and live raw HCI 0x100d reply matches exact spec interleaved AoS layout 00 07 00 02 01 02 02 02 03 02 04 02 05 02 06 04 01 75 00 10 00 02 (including LC3 id=0x06, tr=0x04).
  • boot-health pass (0 failed units, 0 kernel errors on clean boot j1129-174818-e436), omarchy-m-test 0.2.0 pass (0 regressions); checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks on all 3 commits.

Risk: two-way door · layout fixup is gated on BCM4388 and bounds-checked against skb->len and hdr->plen; hci_codec keeps bt_dev_err() for transport/timeout errors and only treats -EINVAL as empty codec capabilities.

…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]>

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and include/net/bluetooth/hci.h.
  • bcm4377_fixup_codecs_v2() is gated solely on BCM4388 (broken_codecs_v2_layout) on linear HCI_EVENT_PKT skbs and bounds-checks skb->len, hdr->evt, hdr->plen, cc->opcode, rp[0] == 0, 3 + std_len, and 3 + std_len + vnd_len. Because hdr->plen <= 255, rp_len <= 252, bounding both std_len and vnd_len to <= 249 < sizeof(tmp) (U8_MAX = 255) with packed sizeof(struct hci_std_codec_v2) == 2 and sizeof(struct hci_vnd_codec_v2) == 5.
  • net/bluetooth/hci_codec.c treats -EINVAL from HCI_OP_READ_LOCAL_CODEC_CAPS as empty capabilities (bt_dev_dbg() + hci_codec_list_add(&hdev->local_codecs, cmd, NULL, NULL, 0) under hci_dev_lock), matching the existing unsupported-command path and preserving bt_dev_err() for transport/timeout errors.
  • hci_bcm4377_test.c (included at the tail of hci_bcm4377.c under CONFIG_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-interleaved 0x100d output including LC3 (0x06, transport 0x04), and passes boot-health and omarchy-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() checks if (rp) before touching rp->num_caps or caps.
  • CI at review time: 3 queued, 1 pending, 1 skipped (0 failures).

maralcbr added a commit to omacom/linux-aurora that referenced this pull request Nov 29, 2026
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]>
@github-actions github-actions Bot added area:wireless Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 29, 2026
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Merge readiness at 40936f13: not ready yet

Check Detail
CI at head ok 4 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 40936f13
Conflicts ok not computed yet
PR text ok Risk: two-way · layout fixup is gated on BCM4388 and bounds-checked against skb->len and hdr->plen; hcicodec keeps btdeverr() for transport/timeout errors and only treats -EINVAL as empty codec capabilities.

Areas: area:wireless

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 30, 2026
@maralcbr

maralcbr commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

J416c (16-inch M2 Max, T6021) at 40936f13 (runtime commits 21bf1ba0 + aa3002fe; 40936f13 is KUnit-only and passed host-tests): boots cleanly with BCM4388 hci0 powered, 0 Failed to read codec capabilities errors, and live raw HCI 0x100d reply in spec AoS layout including LC3 (boot-health and omarchy-m-test pass).

Evidence

Batched carry kernel 7.3.0-lab3ceda392-11ed (lab build b1129-174341-04de, clang 19.1.7 + lld; tree 2298fdf4d88289e9f5bcaf172ae0129e4afb21d6, byte-identical to omacom/linux-aurora tag aurora-7.3.0-2 / c27570ea2936 built as 7.3.0-2-1-ARCH) carrying #3607's two runtime commits (21bf1ba01f00 + aa3002fe6e90) cherry-picked unchanged alongside #3605 (222e0e6b), #3606 (4551c626), and #3608 (87830763). The head commit 40936f133852 touches only drivers/bluetooth/hci_bcm4377_test.c (KUnit tests, zero runtime kernel changes) and passed CI host-tests at 40936f13.

  • Clean boot (j1129-174818-e436): booted in 29 s; boot-health PASS (0 failed units, 0 kernel errors); omarchy-m-test 0.2.0 PASS (0 regressions).
  • Targeted check (j1129-175551-7b35): 0 Bluetooth: hci0: Failed to read codec capabilities (-22) errors (down from 10x on 7.3.0-1-1-ARCH), hci0 present and powered (btmgmt info), live raw HCI 0x100d reply matches exact Bluetooth Core Spec interleaved AoS bytes 00 07 00 02 01 02 02 02 03 02 04 02 05 02 06 04 01 75 00 10 00 02 (including LC3 id=0x06, tr=0x04).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at 40936f133852 (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: the hardware row at 40936f1 that the readiness check found (PR body or comment). CI: linux train L4 = main (after L3) + 34 approved PRs (#3419 dropped: conflicts): Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit ane-boot/clpc/ane-pm/dcp-fabric/dcp-topology/dcp-display/macaudio/asahi/sep all pass, host tests apple-dcp + apple-scaler-recovery pass (the red host-tests on some heads were base failures since fixed on main). The rest of the hosted run is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit e0c85ab into main Dec 1, 2026
6 of 9 checks passed
@RyanTheTide
RyanTheTide deleted the fix/bcm4388-codecs-v2 branch December 1, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:wireless Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants