Skip to content

Bluetooth: btcentauri: Select the transport by PCIe host, not by machine - #2330

Draft
RyanTheTide wants to merge 1 commit into
integration/aurorafrom
spec-m5neo/btcentauri-host
Draft

RyanTheTide wants to merge 1 commit into
integration/aurorafrom
spec-m5neo/btcentauri-host

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem

cen_probe() in drivers/bluetooth/btcentauri.c (line 1011 at 0abc2f3) binds only on apple,j813, apple,j815 and apple,j873g. The list was added with the driver (a03e01f) and grew one board per bring-up (83b16cf / 019c0ab for J873g, cc2dfd9 for J815). None of those commits gives a hardware reason to refuse other boards. Every new N1 machine needs a driver edit, as in #2108, which adds apple,j804 to this list.

Change

The real split is between two transports for the same N1 Beta function (106b:1903). On T6050, btcentauri_t6050.c owns it and binds only behind an apple,t6050-pcie host bridge. cen_probe() now uses that same selector, as centauri_pci.c already does for Wi-Fi: it refuses a function whose host bridge node is apple,t6050-pcie, and keeps the function 2 check. The existing firmware check (execution stage 2, unowned IPC) still decides whether there is anything to talk to. A board whose N1 firmware is not started refuses with -EBUSY as before.

With this, the btcentauri.c line in #2108 is no longer needed. J804 gets Bluetooth once its N1 node and its Wi-Fi board entry land.

Testing

  • Compiled drivers/bluetooth/btcentauri.o (arm64, clang 22, release config, W=1 flags) before and after: no warnings either way. It is the only file changed.
  • Device-tree check over all 137 Apple DTBs in the tree: the boards where cen_probe() goes ahead are the same before and after. Only j813 and j815 (generic ECAM host) and j873g (apple,t8152-pcie) have an N1 behind a non-T6050 host. Every T6050 board has its N1 behind apple,t6050-pcie and stays refused. Boards without an N1 (j700 MT7932, j704 and older Broadcom boards, j804/j833ct with no PCIe node yet) never enumerate a 106b:1903 function.

Still to run

We have no T8142 or T8152 machine. @m0d16l14n1 (J815) and @sithglan (J873g), could you post a quick Bluetooth row with this applied? dmesg | grep -i btcentauri, hciconfig -a (or bluetoothctl show) shows a powered controller, and one LE device pairs.

  • J813: pending
  • J815: pending
  • J873g: pending
Details

Old gate (0abc2f3, drivers/bluetooth/btcentauri.c:1011):

if (!(of_machine_is_compatible("apple,j813") || of_machine_is_compatible("apple,j815") ||
      of_machine_is_compatible("apple,j873g")) ||
    PCI_FUNC(pdev->devfn) != 2)
        return -ENODEV;

New gate: pci_find_host_bridge(pdev->bus)->dev.parent->of_node is not apple,t6050-pcie, and the function number is 2. This is the same test as centauri_pci.c:202-205 and the inverse of btcentauri_t6050.c:936-939, so exactly one of the two drivers can bind any N1 Beta function.

Per-board result (enabled PCIe host nodes found in each DTB, N1 = an N1 function or N1 port is described):

board old gate N1 host new gate
t8142-j813 binds pci-host-ecam-generic binds
t8142-j815 binds pci-host-ecam-generic binds
t8152-j873g binds apple,t8152-pcie binds
t6050-j714c/j714s/j716c/j716s/j775d/k114c/k116s refused apple,t6050-pcie refused
t6050-j775c/j873s/k114s/k116c refused no N1 node yet (would be apple,t6050-pcie) refused
t8152-j804, t8152-j833ct refused no PCIe host node no function, no probe
all other Apple boards refused no N1 (Broadcom or MT7932) no 106b:1903 function, no probe

Left as is, for a separate change:

  • The J813-only sleep handshake in cen_suspend() (btcentauri.c:1167, from 507c53d) and the J813-only Wi-Fi suspend/resume in centauri_wifi.c:2713/2726. The commit says the protocol was verified with the J813 firmware and other boards need qualification. The right selector there is the firmware protocol version, not a board name, and it needs a row on J815/J873g first.
  • The per-board table in centauri.h:74-92. Only part of it is in the device tree. On J873g the port and PHY addresses are the port0/phy0 entries of the PCIe node and the PERST# pad is reset-gpios = <&pinctrl_ap 3 ...>, so those values match. On J813/J815 the host is described as a generic ECAM host: the port block appears only as the MSI controller's reg, and the PHY and PERST# pad are not described at all. The firmware name, board word, root port ID and protocol flags have no device-tree source on T8142/T8152 (on T6050 they are firmware-name and apple,centauri-platform-id in the control node, but the binding forbids those for apple,t8142-centauri-control). Moving them needs binding and DTS changes, so it is not part of this change.

Credit: the driver is by Acelogic and Thomas Glanzmann. J873g support is by Joshua Warren and Thomas Glanzmann, J815 by Nick.

Assisted-by: LLM (Claude:Opus 5.5)

cen_probe() binds only when the machine compatible is apple,j813,
apple,j815 or apple,j873g. The list grew one board at a time as each
N1 machine came up; no board has a hardware reason to be refused. The
one real split is between two transports for the same N1 Beta function
(106b:1903): on T6050 the functions belong to btcentauri_t6050.c, which
binds only behind an "apple,t6050-pcie" host bridge.

Use that same selector here, as the generic Centauri Wi-Fi driver
already does in centauri_pci.c: refuse a function whose host bridge
parent node is "apple,t6050-pcie", keep the function 2 check, and leave
the firmware state check (execution stage 2, unowned IPC) as the gate
for whether there is anything to talk to.

On the device trees in the tree today the result is the same: the only
boards with an N1 behind a non-T6050 host are j813 and j815 (generic
ECAM host) and j873g (apple,t8152-pcie); every T6050 board has its N1
behind apple,t6050-pcie and stays refused. A later board whose device
tree describes its N1 port gets Bluetooth without a driver change.

Fixes: a03e01f ("Bluetooth: add J813 N1 native transport and encrypted connection bring-up")
Cc: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
Cc: Nick <nekreshen@yandex.ru>
Cc: Thomas Glanzmann <thomas@glanzmann.de>
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@sithglan

Copy link
Copy Markdown
Contributor

J813 and J873g rows with this change applied: 022bc851762c on top of each machine's test kernel.

  • J813 (7.3.0-aurora-j813-rows+, arm64: dts: apple: enable the J813 front USB4 port #2238 head + this patch): btcentauri 0000:01:00.2: Beta HCI transport registered; ACL enabled=1, hci0: Native startup accepted; factory address in use. bluetoothctl show: controller j813, Powered: yes, its factory address.
  • J873g (7.3.0-aurora-j873-rows+, J873g: USB4 with hotplug on the rear USB-C ports (T8152 routers, PCIe-C, port monitor; M6 Mac mini) #2178 head + this patch): the first probe, before the N1 firmware runs, is refused as before (error -16: Beta requires running firmware and unowned IPC (exec=0 ipc=0)). Once the firmware is up, the module loads: Beta HCI transport registered, hci0: Native startup accepted; temporary diagnostic address in use. The J873g's loader gives no factory BD address; that's unrelated to this change. bluetoothctl show: Powered: yes.
  • Pairing: with the J873g advertising, the J813 found it in an LE scan, opened an LE connection (type LE Public connected, J873g as peripheral) and paired: Secure Connections with numeric comparison, LegacyPairing: no. Both sides end with LE.Paired/LE.Bonded: yes and BREDR.Paired/BREDR.Bonded: yes, and the LE link stays connected. BlueZ ran the SMP exchange over BR/EDR (link key type 0x08) and derived the LE keys from it, as it does for a dual-mode peer. I removed the bonds again afterwards.
  • One extra data point: swapping the module at runtime is no test of this gate. Both machines answer a reload with Beta detach requires fresh firmware boot, then refuse the probe with -EBUSY at the firmware check. They do reach that check, though, so the new host-bridge gate let both through. The results above are from fresh boots.

No other btcentauri or Bluetooth errors in dmesg on either machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants