Skip to contentSkip to conversation

Add support for IPQ5018 Bluetooth

PATCH In review George Moussalem 6 participants 27 messages Jul 9 – Oct 11

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v5 cover Add support for IPQ5018 Bluetooth

Hello,

This patch series introduces Bluetooth support for IPQ5018.

Bluetooth firmware is loaded by the host into a dedicated reserved memory carveout and authenticated by TrustZone. A Secure Channel Manager (SCM) call safely brings the peripheral core out of reset.

A shared memory ring buffer topology handles runtime data frame transport between the host APSS and the Bluetooth controller. An outgoing APCS IPC bit and an incoming GIC interrupt handle host/guest signaling.

This series has been tested and verified on various IPQ5018 router boards utilizing firmware extracted from GPL distributions, using both mdt and mbn file formats.

[   14.781511] Bluetooth: hci0: QCA Product ID   :0x00000016
[   14.781583] Bluetooth: hci0: QCA SOC Version  :0x20180100
[   14.785926] Bluetooth: hci0: QCA ROM Version  :0x00000100
[   14.791546] Bluetooth: hci0: QCA Patch Version:0x00003ded
[   14.796698] Bluetooth: hci0: QCA controller version 0x01000100
[   14.802217] Bluetooth: hci0: QCA Downloading qca/mpnv10.bin
[   16.393850] Bluetooth: hci0: QCA FW build version: BTFW.MAPLE.1.0.0-00102-MPL_ROM_PATCHZ-1

Best regards,
George Moussalem

---
Changes in v5:
- Updated the bindings file to change from using a memory-region
property to using a reg property for the shared memory area and made
reg a required property.
- Added Bartosz G. to the maintainers list in the bindings file.
- Updated the driver to acquire the memory region as platform resource
using devm_platform_get_and_ioremap_resource()
- Replaced macros with unsafe arithmetic with inline functions that
safely calculate the size by reading values using endian functions le**_to_cpu().
- Update btss_lbuf_size to guard against division by zero and against
the offset extending beyond the total size of the context info struct.
- Updated btqcomipc_send to enqueue packets before releasing the
spinlock to avoid stranding packets in the queue indefinitely.
- Added an explicit DMA read barrier in the RX loop before reading and processing each ring entry to guarantee memory ordering.
- Added strict arithmetic validation for long-message metadata handling
before computing wrap segments and hardened the non-contiguous path to
prevent underflow.
- Hardened split-segment firmware loading error handling. If
request_firmware() for a segment fails, the code now exits that path immediately instead of falling through to memcpy_toio() and added
explicit split-file size validation before copy.
- Updated HCI dev close path state teardown to avoid stale transport
stale after PAS shutdown. btqcomipc_close() now explicitly sets
running state to false under lock after shutdown.
- Made IRQ registration safe against spurious interrupts by keeping the
line disabled after request (flags includes now IRQF_NO_AUTOEN).
IRQ is now enabled only in btqcomipc_open() right before firmware boot
and disabled again on open-failure and close paths.
- Reordered remove-path teardown to eliminate worker vs HCI lifetime
race. It now unregisters HCI first to stop new traffic, then calls btqcomipc_deinit() to stop async processing, and only then frees hdev.
- Removed reserved memory area from the dtsi, moved bluetooth node under
the soc node, and added unit address and reg property.
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Ordered switch statements in btqca.c. NOTE: left enum qca_bt_soc_type unordered in the header file as the btqca driver has conditionally
checks whether bt_soc_type is above a certain value:
'if (soc_type >= QCA_WCN3991)' is found in 5 places
- Fixed TX path serialization by protecting btqcomipc_send and
btss_send ring access with desc->lock, preventing concurrent updates
of ring indices and free counters from TX and worker contexts.
- Fixed and simplified firmware ring traversal to decode little-endian
next and translate firmware offsets via TO_APPS_ADDR in all ring
walks, avoiding invalid pointer dereferences.
- Added short-message RX length validation (msg_len must not exceed IPC_MSG_PLD_SZ when not long message), preventing out-of-bounds read
from inline shared-memory payloads.
- Fixed RX allocation failure behavior to advance ring index and
continue, preventing permanent RX ring stall on transient kmalloc
failures.
- Replace macro for calculting large buffer size that performed unsafe arithmetic by an inline function that safely calculates the size by
reading values using endian functions le**_to_cpu().
- Declared aux_ptr as a zero-initialized struct as opposed to using
memset and changed struct definition by updating its member to use
u32 as opposed to __le32 as these values aren't set by firmware and
need not be validated on endianness.
- Fixed long-message slot leak when short TX ring is full by
snapshotting and rolling back long-buffer accounting on allocation-success/short-ring-fail path.
- Updated firmware load logic to remove call to qcom_mdt_pas_init for
which the export was recently removed and replaced it by calls to
read the metadata and the validation of it using SCM.
NOTE: Sashiko correctly pointed out that the firmware ELF/mdt headers
weren't validated in the driver. However, this is done by the call to qcom_mdt_read_metadata which returns -EINVAL if the mdt header isn't
valid.
- Hardened firmware segment bounds checks against integer overflow by
using subtraction form (filesz <= mem_size - vaddr).
- Replaced unsafe firmware split name rewrite with validated stem
handling and kasprintf formatting, removing underflow/overflow risk.
- Converted workqueue allocation to devm_alloc_ordered_workqueue to fix workqueue leak in IRQ registration failure path.
- Added cleanup path in btqcomipc_open to shut down controller on
startup timeout, avoiding leaving peripheral powered after failed open
- Reordered probe sequence to allocate/attach hdev before IRQ
registration, eliminating early-spurious-IRQ dereference window for desc->hdev.
- Reordered remove path to unregister/free hdev before driver deinit,
preventing send path from racing against queue/work teardown.
- Corrected HCI command packet length parsing to use 8-bit plen directly
instead of using le16_to_cpu.
- Fixed endianness and address translation in TX ACK processing path.
Converted firmware-owned ring metadata before use in btss_process_ack:
rbuf base offset, msg header, long-message pointer, and message length
are now read via le32_to_cpu or le16_to_cpu prior to reclaim logic.
- Added explicit producer ordering barrier in TX ring publish path.
Inserted dma_wmb between payload or header writes and widx update so
firmware cannot observe producer index advancement before data becomes visible.
- Removed info message printing FW build info as that was recently
introduced in the kernel in commit bdea21b3be43
- Added dependency on OF and ARCH_QCOM symbols to Kconfig. In addition,
also select QCOM_MDT_LOADER and QCOM_SCM.
- Removed syscon compatible from mailbox node, avoiding dt_binding_check failures and update the syscon acquisition logic in driver probe
accordingly.
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Consolidated the SCM and helper call into one function which now
checks availability of the SCM call inline.
- Changed argument to boolean type to set ECO power mode on or off as
opposed to passing a raw power mode value.
- Removed unneeded parentheses in if statement
- Declared aux_ptr as a zero-initialized struct as opposed to using
memset
- Changed for loop to a while loop for better readability
- Reordered function definition of btqcomipc_update_stats to avoid the
need for a forward declaration.
- Removed unneeded header files from btqcomipc.c (bits.h, device.h,
init.h, kernel.h, of_irq.h, types.h)
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- removed unused struct member btss_reset from m0_btss struct.
- used devm_reset_control_get_exclusive_deasserted to acquire and
deassert btss_reset in one call. No need to explicitly assert upon
unbind since devres will handle it.
- As per Bjorn's comments, collapsed the rproc and BT driver into one
which now handles firmware loading and transport.
- As per further review comments and above change, squashed the two
devicetree bindings into one to represent the Bluetooth controller
- Added new SCM call to drive Bluetooth power modes. Based on testing on
more router boards, this is required during start/stop sequences to
avoid the controller hanging. This is only supported on relatively
newer QSEE versions, so the SCM call is checked for availability
before use.
- Refactored resource lifecycle management in the driver so that IRQ and
work queue are managed at the driver level (probe/remove) while FW
loading and powering on/off the controller is handled upon hdev
open/close.
- Consolidated TX send functions for custom IPC and HCI frames into one
and solved a potential NULL pointer dereference issue under TX
pressure.
- Replace code to load and initialize firmware metadate by existing qcom_mdt_pas_init function.
- Solved an off byone calculation error in the RX parser.
- Added entry to MAINTAINERS file
- Link to v1: https://lore.kernel.org/r/[email protected]

---
George Moussalem (6):
dt-bindings: net: bluetooth: Document Qualcomm IPQ5018 Bluetooth controller
Bluetooth: btqca: Add IPQ5018 support
firmware: qcom: scm: Add support for setting Bluetooth power modes
Bluetooth: Introduce Qualcomm IPQ5018 IPC based HCI driver
arm64: dts: qcom: ipq5018: add node required for Bluetooth support
MAINTAINERS: Add IPQ5018 driver to Qualcomm Bluetooth driver entry

 .../bindings/net/bluetooth/qcom,ipq5018-bt.yaml    |   87 ++
 MAINTAINERS                                        |    1 +
 arch/arm64/boot/dts/qcom/ipq5018.dtsi              |   16 +
 drivers/bluetooth/Kconfig                          |   14 +
 drivers/bluetooth/Makefile                         |    1 +
 drivers/bluetooth/btqca.c                          |   16 +
 drivers/bluetooth/btqca.h                          |    3 +
 drivers/bluetooth/btqcomipc.c                      | 1230 ++++++++++++++++++++
 drivers/firmware/qcom/qcom_scm.c                   |   44 +
 drivers/firmware/qcom/qcom_scm.h                   |    1 +
 include/linux/firmware/qcom/qcom_scm.h             |    1 +
 11 files changed, 1414 insertions(+)

---
base-commit: ca75417ab1793f23b3ddc91869f0809b593d6954
change-id: 20260625-ipq5018-bluetooth-06ff66c9d753
prerequisite-message-id: <[email protected]>
prerequisite-patch-id: 467ba5e0fde0e9a1e9d0a6faf3d22ba2126c62a7
prerequisite-patch-id: 9168930e40551e842c8171d5433a6f39ad4b78a4
prerequisite-patch-id: 64fecfbd1e085d7d2ab0ae23295ca34ec8e14c5e
prerequisite-patch-id: 7bf282ed9312b2ffdbe420429bbe355622620272
prerequisite-patch-id: 29a7d652948d13f91bdd4fc5fb8e6dbcd6e5fcc5
prerequisite-patch-id: c03136820a7749fd9630080e6d4459a298b3b630
prerequisite-patch-id: 43975fc425bf2f5dd5c1de66aaa78c4b4bde568c
prerequisite-patch-id: 75caa99e3bbcdf41b6462b9f5f703bea1d4a65fa
prerequisite-patch-id: b9b2a2f80a4827b457166b20f54644e57d90b824

Best regards,

Signature · 1 line
George Moussalem <[email protected]>
#1 lore raw

PATCH v5 1/6 dt-bindings: net: bluetooth: Document Qualcomm IPQ5018 Bluetooth controller

Document the Qualcomm IPQ5018 Bluetooth controller.

---
 .../bindings/net/bluetooth/qcom,ipq5018-bt.yaml    | 87 ++++++++++++++++++++++
 1 file changed, 87 insertions(+)
Documentation/devicetree/bindings/net/bluetooth/qcom,ipq5018-bt.yaml new file +87 -0
new file mode 100644
index 000000000000..6bd74c01b821
@@ -0,0 +1,87 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/bluetooth/qcom,ipq5018-bt.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm IPQ5018 Bluetooth
+
+maintainers:
+  - Bartosz Golaszewski <[email protected]>
+  - George Moussalem <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - qcom,ipq5018-bt
+
+  reg:
+    items:
+      - description: |
+          Shared memory for firmware loading and runtime data transport between
+          the host and the Bluetooth controller.
+
+  clocks:
+    items:
+      - description: Bluetooth Subsystem low power oscillator clock
+
+  clock-names:
+    items:
+      - const: lpo
+
+  firmware-name:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  qcom,ipc:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - items:
+          - description: syscon node representing the APCS registers
+          - description: offset to the register within the syscon
+          - description: IPC bit within the register
+    description: |
+      The outgoing IPC bit used for signaling the Bluetooth controller of a host
+      event or for sending an ACK if the remote processor expects it.
+
+  resets:
+    items:
+      - description: Bluetooth Subsystem reset
+
+required:
+  - compatible
+  - clocks
+  - clock-names
+  - firmware-name
+  - interrupts
+  - qcom,ipc
+  - reg
+  - resets
+
+allOf:
+  - $ref: bluetooth-controller.yaml#
+  - $ref: qcom,bluetooth-common.yaml
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/qcom,gcc-ipq5018.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/reset/qcom,gcc-ipq5018.h>
+
+    bluetooth@7000000 {
+      compatible = "qcom,ipq5018-bt";
+      reg = <0x07000000 0x58000>;
+
+      firmware-name = "qca/bt_fw_patch.mbn";
+
+      clocks = <&gcc GCC_BTSS_LPO_CLK>;
+      clock-names = "lpo";
+      resets = <&gcc GCC_BTSS_BCR>;
+
+      qcom,ipc = <&apcs_glb 8 23>;
+      interrupts = <GIC_SPI 162 IRQ_TYPE_EDGE_RISING>;
+    };
Signature · 1 line
2.53.0
#2 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1124520

---Test result---

Test Summary:

CheckPatch                    FAIL      5.36 seconds
VerifyFixes                   PASS      0.07 seconds
VerifySignedoff               PASS      0.07 seconds
GitLint                       FAIL      1.23 seconds
SubjectPrefix                 FAIL      0.43 seconds
BuildKernel                   PASS      27.68 seconds
CheckAllWarning               PASS      30.76 seconds
CheckSparse                   PASS      28.91 seconds
BuildKernel32                 PASS      27.09 seconds
CheckKernelLLVM               SKIP      0.00 seconds
TestRunnerSetup               PASS      503.36 seconds
TestRunner_l2cap-tester       PASS      58.63 seconds
TestRunner_iso-tester         PASS      75.61 seconds
TestRunner_bnep-tester        PASS      19.34 seconds
TestRunner_mgmt-tester        FAIL      214.55 seconds
TestRunner_rfcomm-tester      PASS      25.23 seconds
TestRunner_sco-tester         PASS      32.47 seconds
TestRunner_ioctl-tester       PASS      25.77 seconds
TestRunner_mesh-tester        FAIL      24.84 seconds
TestRunner_smp-tester         PASS      23.02 seconds
TestRunner_userchan-tester    PASS      19.89 seconds
TestRunner_6lowpan-tester     PASS      22.64 seconds
IncrementalBuild              PASS      33.55 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[v5,1/6] dt-bindings: net: bluetooth: Document Qualcomm IPQ5018 Bluetooth controller
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #96:
new file mode 100644

total: 0 errors, 1 warnings, 87 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/patch/14674953.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

[v5,4/6] Bluetooth: Introduce Qualcomm IPQ5018 IPC based HCI driver
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #143:
new file mode 100644

total: 0 errors, 1 warnings, 1257 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/patch/14674958.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[v5,1/6] dt-bindings: net: bluetooth: Document Qualcomm IPQ5018 Bluetooth controller

1: T1 Title exceeds max length (84>80): "[v5,1/6] dt-bindings: net: bluetooth: Document Qualcomm IPQ5018 Bluetooth controller"
##############################
Test: SubjectPrefix - FAIL
Desc: Check subject contains "Bluetooth" prefix
Output:
"Bluetooth: " prefix is not specified in the subject
"Bluetooth: " prefix is not specified in the subject
"Bluetooth: " prefix is not specified in the subject
"Bluetooth: " prefix is not specified in the subject
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success Failed 0.236 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases

Mesh - Send cancel - 1                               Timed out    1.824 seconds
Mesh - Send cancel - 2                               Timed out    1.992 seconds

https://github.com/bluez/bluetooth-next/pull/417

---
Regards,
Linux Bluetooth

#3 lore raw

PATCH v5 2/6 Bluetooth: btqca: Add IPQ5018 support

In reply to George Moussalem

Add the IPQ5018 SoC type and support for loading its firmware.

The firmware tested has been taken from GPL sources of various router boards. Firmware files needed are:
- qca/bt_fw_patch.mbn
- qca/mpnv10.bin

---
 drivers/bluetooth/btqca.c | 16 ++++++++++++++++
 drivers/bluetooth/btqca.h |  3 +++
 2 files changed, 19 insertions(+)
drivers/bluetooth/btqca.c +16 -0
index 08600b0fc041..eed30a4480e0 100644
@@ -361,6 +361,9 @@ static int qca_tlv_check_data(struct hci_dev *hdev,
 		break;
 
 	case TLV_TYPE_NVM:
+		if (soc_type == QCA_IPQ5018)
+			break;
+
 		if (fw_size < sizeof(struct tlv_type_hdr))
 			return -EINVAL;
 
@@ -778,6 +781,9 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 	else
 		rom_ver = ((soc_ver & 0x00000f00) >> 0x04) | (soc_ver & 0x0000000f);
 
+	if (soc_type == QCA_IPQ5018)
+		goto download_nvm;
+
 	if (soc_type == QCA_WCN6750)
 		qca_send_patch_config_cmd(hdev);
 
@@ -865,6 +871,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 	if (soc_type == QCA_QCA2066 || soc_type == QCA_WCN7850)
 		qca_read_fw_board_id(hdev, &boardid);
 
+download_nvm:
 	/* Download NVM configuration */
 	config.type = TLV_TYPE_NVM;
 	if (firmware_name) {
@@ -878,6 +885,10 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 		}
 	} else {
 		switch (soc_type) {
+		case QCA_IPQ5018:
+			snprintf(config.fwname, sizeof(config.fwname),
+				 "qca/mpnv%02x.bin", rom_ver);
+			break;
 		case QCA_QCA2066:
 			qca_get_nvm_name_by_board(config.fwname,
 						  sizeof(config.fwname),
@@ -942,7 +953,11 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 		return err;
 	}
 
+	if (soc_type == QCA_IPQ5018)
+		msleep(NVM_READY_DELAY_MS);
+
 	switch (soc_type) {
+	case QCA_IPQ5018:
 	case QCA_QCA2066:
 	case QCA_QCA6390:
 	case QCA_WCN3991:
@@ -982,6 +997,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 	bt_dev_dbg(hdev, "QCA HCI_RESET succeed");
 
 	switch (soc_type) {
+	case QCA_IPQ5018:
 	case QCA_WCN3991:
 	case QCA_WCN6750:
 	case QCA_WCN6855:
drivers/bluetooth/btqca.h +3 -0
index 8f3c1b1c77b3..343cd62d1137 100644
@@ -54,6 +54,8 @@
 #define QCA_HSP_GF_SOC_ID		0x1200
 #define QCA_HSP_GF_SOC_MASK		0x0000ff00
 
+#define NVM_READY_DELAY_MS		1500
+
 enum qca_baudrate {
 	QCA_BAUDRATE_115200	= 0,
 	QCA_BAUDRATE_57600,
@@ -158,6 +160,7 @@ enum qca_btsoc_type {
 	QCA_WCN6750,
 	QCA_WCN6855,
 	QCA_WCN7850,
+	QCA_IPQ5018,
 };
 
 #if IS_ENABLED(CONFIG_BT_QCA)
Signature · 1 line
2.53.0
#4 lore raw

Re: [PATCH v5 2/6] Bluetooth: btqca: Add IPQ5018 support

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Incomplete implementation resulting in dead code: the QCA_IPQ5018 SoC type is not mapped in any…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Incomplete implementation resulting in dead code: the QCA_IPQ5018 SoC type is not mapped in any device tree match table.
- [High] The implementation unconditionally skips downloading the required rampatch firmware qca/bt_fw_patch.mbn. --

--- Patch [2]: [PATCH v5 2/6] Bluetooth: btqca: Add IPQ5018 support --- commit 388a60ab03a30caa9b4a4e153c1ccb4a83f4283c
Author: George Moussalem <[email protected]>

Bluetooth: btqca: Add IPQ5018 support

This commit adds the IPQ5018 SoC type and support for loading its firmware for Bluetooth support.

drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, · line 783

Quoted 11 lines
drivers/bluetooth/btqca.c +3 -0
index 22b08ab05b829..f5ded8fb1e3ab 100644
@@ -775,6 +778,9 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 	else
 		rom_ver = ((soc_ver & 0x00000f00) >> 0x04) | (soc_ver & 0x0000000f);
 
+	if (soc_type == QCA_IPQ5018)
+		goto download_nvm;
+

[Severity: High]
The commit message explicitly states that qca/bt_fw_patch.mbn is needed, but doesn't this goto statement unconditionally skip the entire rampatch download block?

If a firmware-name is provided via the device tree, it appears it would also be incorrectly loaded as the NVM configuration instead of the rampatch due to this jump.

[ ... ]

drivers/bluetooth/btqca.h enum qca_btsoc_type { · line 164

Quoted 10 lines
drivers/bluetooth/btqca.h +1 -0
index 8f3c1b1c77b3d..343cd62d11371 100644
@@ -158,6 +160,7 @@ enum qca_btsoc_type {
 	QCA_WCN6750,
 	QCA_WCN6855,
 	QCA_WCN7850,
+	QCA_IPQ5018,
 };

[Severity: High]
Is there a missing device tree match mapping for QCA_IPQ5018 in hci_qca.c?

Without adding an entry like qcom,ipq5018-bt to qca_bluetooth_of_match, it seems the driver will never probe the device and soc_type will never be set to QCA_IPQ5018. This would make the newly added firmware loading logic completely unreachable.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#5 lore raw

Re: [PATCH v5 2/6] Bluetooth: btqca: Add IPQ5018 support

adding Bartosz, Konrad, and Dmitry for awareness.

Quoted 31 lines · On 7/9/26 13:31, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Incomplete implementation resulting in dead code: the QCA_IPQ5018 SoC type is not mapped in any device tree match table.
- [High] The implementation unconditionally skips downloading the required rampatch firmware qca/bt_fw_patch.mbn. --

--- Patch [2]: [PATCH v5 2/6] Bluetooth: btqca: Add IPQ5018 support --- commit 388a60ab03a30caa9b4a4e153c1ccb4a83f4283c
Author: George Moussalem <[email protected]>

Bluetooth: btqca: Add IPQ5018 support

This commit adds the IPQ5018 SoC type and support for loading its firmware for Bluetooth support.

drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, · line 783

Quoted 11 lines
drivers/bluetooth/btqca.c +3 -0
index 22b08ab05b829..f5ded8fb1e3ab 100644
@@ -775,6 +778,9 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 	else
 		rom_ver = ((soc_ver & 0x00000f00) >> 0x04) | (soc_ver & 0x0000000f);
 
+	if (soc_type == QCA_IPQ5018)
+		goto download_nvm;
+

[Severity: High]
The commit message explicitly states that qca/bt_fw_patch.mbn is needed, but doesn't this goto statement unconditionally skip the entire rampatch download block?

Quoted 3 lines

If a firmware-name is provided via the device tree, it appears it would also be incorrectly loaded as the NVM configuration instead of the rampatch due to this jump.

firmware loading is handled in the driver itself. The patch mpvn10.bin is handled here, hence the goto to skip the firmware loading section.

Quoted 17 lines

[ ... ]

drivers/bluetooth/btqca.h enum qca_btsoc_type { · line 164

Quoted 10 lines
drivers/bluetooth/btqca.h +1 -0
index 8f3c1b1c77b3d..343cd62d11371 100644
@@ -158,6 +160,7 @@ enum qca_btsoc_type {
 	QCA_WCN6750,
 	QCA_WCN6855,
 	QCA_WCN7850,
+	QCA_IPQ5018,
 };

[Severity: High]
Is there a missing device tree match mapping for QCA_IPQ5018 in hci_qca.c?

Quoted 5 lines

Without adding an entry like qcom,ipq5018-bt to qca_bluetooth_of_match, it seems the driver will never probe the device and soc_type will never be set to QCA_IPQ5018. This would make the newly added firmware loading logic completely unreachable.

the compatible is found in its own dedicated driver: btqcomipc.c

#6 lore raw

PATCH v5 3/6 firmware: qcom: scm: Add support for setting Bluetooth power modes

In reply to George Moussalem

The Bluetooth subsystem (BTSS) on the IPQ5018 SoC supports setting power modes which are required to be configured through a Secure Channel Manager (SCM) call to TrustZone. However, not all Trusted Execution Environment (QSEE) images support this call, so first check if the call is available.

---
 drivers/firmware/qcom/qcom_scm.c       | 44 ++++++++++++++++++++++++++++++++++
 drivers/firmware/qcom/qcom_scm.h       |  1 +
 include/linux/firmware/qcom/qcom_scm.h |  1 +
 3 files changed, 46 insertions(+)
drivers/firmware/qcom/qcom_scm.c +44 -0
index 9b06a69d3a6d..d51e3f4339d8 100644
@@ -1094,6 +1094,50 @@ bool qcom_scm_pas_supported(u32 pas_id)
 }
 EXPORT_SYMBOL_GPL(qcom_scm_pas_supported);
 
+/**
+ * qcom_scm_pas_set_bluetooth_power_mode() - Configure power mode for the
+ *					     Bluetooth subsystem (BTSS)
+ * @pas_id:	peripheral authentication service id
+ * @eco_mode:	true for ECO mode, false for normal operation
+ *
+ * Return: 0 on success, negative errno on failure.
+ * Returns -EOPNOTSUPP if the firmware configuration call is unavailable.
+ */
+int qcom_scm_pas_set_bluetooth_power_mode(u32 pas_id, bool eco_mode)
+{
+	struct qcom_scm_desc desc = {
+		.svc = QCOM_SCM_SVC_PIL,
+		.cmd = QCOM_SCM_PIL_PAS_BT_PWR_MODE,
+		.arginfo = QCOM_SCM_ARGS(2),
+		.args[0] = pas_id,
+		.args[1] = eco_mode ? 0x4 : 0x0,
+		.owner = ARM_SMCCC_OWNER_SIP,
+	};
+	struct qcom_scm_res res;
+	int ret;
+
+	if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL,
+					  QCOM_SCM_PIL_PAS_BT_PWR_MODE))
+		return -EOPNOTSUPP;
+
+	ret = qcom_scm_clk_enable();
+	if (ret)
+		return ret;
+
+	ret = qcom_scm_bw_enable();
+	if (ret)
+		goto disable_clk;
+
+	ret = qcom_scm_call(__scm->dev, &desc, &res);
+	qcom_scm_bw_disable();
+
+disable_clk:
+	qcom_scm_clk_disable();
+
+	return ret ? : res.result[0];
+}
+EXPORT_SYMBOL_GPL(qcom_scm_pas_set_bluetooth_power_mode);
+
 static int __qcom_scm_pas_mss_reset(struct device *dev, bool reset)
 {
 	struct qcom_scm_desc desc = {
drivers/firmware/qcom/qcom_scm.h +1 -0
index caab80a73e17..5579df5a2aca 100644
@@ -105,6 +105,7 @@ int qcom_scm_shm_bridge_enable(struct device *scm_dev);
 #define QCOM_SCM_PIL_PAS_SHUTDOWN	0x06
 #define QCOM_SCM_PIL_PAS_IS_SUPPORTED	0x07
 #define QCOM_SCM_PIL_PAS_MSS_RESET	0x0a
+#define QCOM_SCM_PIL_PAS_BT_PWR_MODE	0x21
 #define QCOM_SCM_PIL_PAS_GET_RSCTABLE	0x21
 
 #define QCOM_SCM_SVC_IO			0x05
include/linux/firmware/qcom/qcom_scm.h +1 -0
index 5747bd191bf1..aca937ac8ddd 100644
@@ -93,6 +93,7 @@ struct resource_table *qcom_scm_pas_get_rsc_table(struct qcom_scm_pas_context *c
 						  size_t *output_rt_size);
 
 int qcom_scm_pas_prepare_and_auth_reset(struct qcom_scm_pas_context *ctx);
+int qcom_scm_pas_set_bluetooth_power_mode(u32 pas_id, bool eco_mode);
 
 int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val);
 int qcom_scm_io_writel(phys_addr_t addr, unsigned int val);
Signature · 1 line
2.53.0
#7 lore raw

Re: [PATCH v5 3/6] firmware: qcom: scm: Add support for setting Bluetooth power modes

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The new `QCOM_SCM_PIL_PAS_BT_PWR_MODE` macro uses the exact same command ID (`0x21`) as the…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The new QCOM_SCM_PIL_PAS_BT_PWR_MODE macro uses the exact same command ID (0x21) as the existing QCOM_SCM_PIL_PAS_GET_RSCTABLE macro within the QCOM_SCM_SVC_PIL service. --

--- Patch [3]: [PATCH v5 3/6] firmware: qcom: scm: Add support for setting Bluetooth power modes --- commit 7001f29bdf69c1e84287e5d8734b48feda414e41
Author: George Moussalem <[email protected]>

firmware: qcom: scm: Add support for setting Bluetooth power modes

The Bluetooth subsystem (BTSS) on the IPQ5018 SoC supports setting power modes which are configured through a Secure Channel Manager (SCM) call to TrustZone. This commit adds a function to perform this call after checking if the feature is supported by the QSEE image.

drivers/firmware/qcom/qcom_scm.h int qcom_scm_shm_bridge_enable(struct device *scm_dev); · line 109

Quoted 10 lines
drivers/firmware/qcom/qcom_scm.h +1 -0
index caab80a73e17f..5579df5a2aca7 100644
@@ -105,6 +105,7 @@ int qcom_scm_shm_bridge_enable(struct device *scm_dev);
 #define QCOM_SCM_PIL_PAS_SHUTDOWN	0x06
 #define QCOM_SCM_PIL_PAS_IS_SUPPORTED	0x07
 #define QCOM_SCM_PIL_PAS_MSS_RESET	0x0a
+#define QCOM_SCM_PIL_PAS_BT_PWR_MODE	0x21
 #define QCOM_SCM_PIL_PAS_GET_RSCTABLE	0x21

[Severity: High]
Is it intended for QCOM_SCM_PIL_PAS_BT_PWR_MODE to use the exact same command ID (0x21) as QCOM_SCM_PIL_PAS_GET_RSCTABLE?

Because both definitions share 0x21 within the QCOM_SCM_SVC_PIL service, when __qcom_scm_is_call_available() queries the firmware for QCOM_SCM_PIL_PAS_BT_PWR_MODE, it will falsely return true on any SoC that already supports GET_RSCTABLE.

This would allow qcom_scm_pas_set_bluetooth_power_mode() to incorrectly proceed and execute a 2-argument SCM call to TrustZone. Could this cause the firmware to route the call to the GET_RSCTABLE handler (which expects 5 arguments, including physical addresses for DMA), potentially leading to a Secure World memory fault?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#8 lore raw

Re: [PATCH v5 3/6] firmware: qcom: scm: Add support for setting Bluetooth power modes

adding Bartosz, Konrad, and Dmitry for awareness.

Quoted 15 lines · On 7/9/26 13:27, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The new QCOM_SCM_PIL_PAS_BT_PWR_MODE macro uses the exact same command ID (0x21) as the existing QCOM_SCM_PIL_PAS_GET_RSCTABLE macro within the QCOM_SCM_SVC_PIL service. --

--- Patch [3]: [PATCH v5 3/6] firmware: qcom: scm: Add support for setting Bluetooth power modes --- commit 7001f29bdf69c1e84287e5d8734b48feda414e41
Author: George Moussalem <[email protected]>

firmware: qcom: scm: Add support for setting Bluetooth power modes

The Bluetooth subsystem (BTSS) on the IPQ5018 SoC supports setting power modes which are configured through a Secure Channel Manager (SCM) call to TrustZone. This commit adds a function to perform this call after checking if the feature is supported by the QSEE image.

Quoted 14 lines

drivers/firmware/qcom/qcom_scm.h int qcom_scm_shm_bridge_enable(struct device *scm_dev); · line 109

Quoted 10 lines
drivers/firmware/qcom/qcom_scm.h +1 -0
index caab80a73e17f..5579df5a2aca7 100644
@@ -105,6 +105,7 @@ int qcom_scm_shm_bridge_enable(struct device *scm_dev);
 #define QCOM_SCM_PIL_PAS_SHUTDOWN	0x06
 #define QCOM_SCM_PIL_PAS_IS_SUPPORTED	0x07
 #define QCOM_SCM_PIL_PAS_MSS_RESET	0x0a
+#define QCOM_SCM_PIL_PAS_BT_PWR_MODE	0x21
 #define QCOM_SCM_PIL_PAS_GET_RSCTABLE	0x21

[Severity: High]
Is it intended for QCOM_SCM_PIL_PAS_BT_PWR_MODE to use the exact same command ID (0x21) as QCOM_SCM_PIL_PAS_GET_RSCTABLE?

Yes, this is intended. This is the documented power mode register for Bluetooth on IPQ5018.

Quoted 6 lines

Because both definitions share 0x21 within the QCOM_SCM_SVC_PIL service, when __qcom_scm_is_call_available() queries the firmware for QCOM_SCM_PIL_PAS_BT_PWR_MODE, it will falsely return true on any SoC that already supports GET_RSCTABLE.

Quoted 6 lines

This would allow qcom_scm_pas_set_bluetooth_power_mode() to incorrectly proceed and execute a 2-argument SCM call to TrustZone. Could this cause the firmware to route the call to the GET_RSCTABLE handler (which expects 5 arguments, including physical addresses for DMA), potentially leading to a Secure World memory fault?

Best regards,
George

#9 lore raw

PATCH v5 4/6 Bluetooth: Introduce Qualcomm IPQ5018 IPC based HCI driver

In reply to George Moussalem

Add support for the Bluetooth controller found in the IPQ5018 SoC. This driver implements firmware loading and the transport layer between the HCI core and the Bluetooth controller.

The firmware is loaded by the host into the memory area shared by the host and the controller and is authenticated by TrustZone. A Secure Channel Manager (SCM) call brings the peripheral core out of reset.

A shared memory ring buffer topology handles runtime data frame transport between the host APSS and the controller.

An outgoing APCS IPC bit and an incoming GIC interrupt handle host/guest signaling.

---
 drivers/bluetooth/Kconfig     |   14 +
 drivers/bluetooth/Makefile    |    1 +
 drivers/bluetooth/btqcomipc.c | 1230 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1245 insertions(+)
drivers/bluetooth/Kconfig +14 -0
index 4e8c24d757e9..a2d82f27f07a 100644
@@ -413,6 +413,20 @@ config BT_MTKUART
 	  Say Y here to compile support for MediaTek Bluetooth UART devices
 	  into the kernel or say M to compile it as module (btmtkuart).
 
+config BT_QCOMIPC
+	tristate "Qualcomm IPQ5018 IPC based HCI support"
+	depends on OF && ARCH_QCOM
+	select BT_QCA
+	select QCOM_MDT_LOADER
+	select QCOM_SCM
+	help
+	  Qualcomm IPQ5018 IPC based HCI driver.
+	  This driver is used to load firmware and bridge HCI data onto shared
+	  memory between the host and the Bluetooth controller.
+
+	  Say Y here to compile support for HCI over Qualcomm IPC into the
+	  kernel or say M to compile as a module.
+
 config BT_QCOMSMD
 	tristate "Qualcomm SMD based HCI support"
 	depends on RPMSG || (COMPILE_TEST && RPMSG=n)
drivers/bluetooth/Makefile +1 -0
index e6b1c1180d1d..05f19047bed0 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_BT_MRVL)		+= btmrvl.o
 obj-$(CONFIG_BT_MRVL_SDIO)	+= btmrvl_sdio.o
 obj-$(CONFIG_BT_MTKSDIO)	+= btmtksdio.o
 obj-$(CONFIG_BT_MTKUART)	+= btmtkuart.o
+obj-$(CONFIG_BT_QCOMIPC)	+= btqcomipc.o
 obj-$(CONFIG_BT_QCOMSMD)	+= btqcomsmd.o
 obj-$(CONFIG_BT_BCM)		+= btbcm.o
 obj-$(CONFIG_BT_RTL)		+= btrtl.o
drivers/bluetooth/btqcomipc.c new file +1230 -0

1,230 lines not on this page · raw message

Signature · 1 line
2.53.0
#10 lore raw

Re: [PATCH v5 4/6] Bluetooth: Introduce Qualcomm IPQ5018 IPC based HCI driver

Thank you for your contribution! Sashiko AI review found 11 potential issue(s) to consider: - [Critical] Unvalidated ring buffer offsets read from shared memory allow arbitrary kernel memory read…

Thank you for your contribution! Sashiko AI review found 11 potential issue(s) to consider:
- [Critical] Unvalidated ring buffer offsets read from shared memory allow arbitrary kernel memory read and write via TO_APPS_ADDR.
- [High] Missing bounds check on ELF segment p_memsz during firmware load allows out-of-bounds memory zeroing.
- [High] Inconsistent spinlock context for desc->lock causes a potential deadlock between btss_worker() and btqcomipc_send().
- [High] Unvalidated ring buffer linked list traversal allows untrusted firmware to hang the host CPU.
- [High] Flawed mathematical validation for wrapped long RX frames allows out-of-bounds I/O memory reads.
- [High] Missing workqueue cancellation and unsafe firmware shutdown order in btqcomipc_close() leads to a hardware fault or UAF.
- [High] Time-of-check to time-of-use (TOCTOU) and missing size bounds checks on rx_ctxt->total_size lead to an out-of-bounds tx_ctxt pointer.
- [High] Missing validation of buffer counts from shared memory triggers divide-by-zero panics.
- [Medium] Directly sending short messages bypasses queued long messages, violating HCI FIFO ordering.
- [Medium] Overwriting the ack parameter in btss_process_rx leads to silently dropped interrupt ACKs.
- [Medium] The driver accesses I/O-mapped memory via direct C pointer dereferences, causing potential alignment faults.
--

--- Patch [4]: [PATCH v5 4/6] Bluetooth: Introduce Qualcomm IPQ5018 IPC based HCI driver --- commit bc9200dabd0dfb475dc74e5c716cbd6ea1df35df
Author: George Moussalem <[email protected]>
Subject: Bluetooth: Introduce Qualcomm IPQ5018 IPC based HCI driver

This commit adds support for the Bluetooth controller found in the IPQ5018 SoC. It implements firmware loading and the transport layer between the HCI core and the controller using a shared memory ring buffer topology.

Quoted 4 lines
drivers/bluetooth/btqcomipc.c +0 -2
index 0000000000000..9d71fe6117723
--- /dev/null
--- b/drivers/bluetooth/btqcomipc.c

[ ... ]

drivers/bluetooth/btqcomipc.c static int btss_send(struct qcom_btss *desc, u16 msg_hdr, · line 283

Quoted 10 lines
drivers/bluetooth/btqcomipc.c +0 -0
@@ -275,12 +275,13 @@ static int btss_send(struct qcom_btss *desc, u16 msg_hdr,
     if (is_sbuf_full || is_lbuf_full)
         hdr |= IPC_HDR_REQ_ACK;
 
 complete_tx:
     rbuf->msg_hdr = cpu_to_le16(hdr);
     rbuf->len = cpu_to_le16(len);
 
     dma_wmb();
 

[Severity: High]
Does this modulo operation rely on desc->tx_ctxt->smsg_buf_cnt being non-zero?

If the firmware modifies the count to zero in shared memory, could this cause a kernel panic via division-by-zero?

Quoted 6 lines
drivers/bluetooth/btqcomipc.c +0 -0
     rinfo->widx = (rinfo->widx + 1) % desc->tx_ctxt->smsg_buf_cnt;
 
     regmap_set_bits(desc->regmap, desc->offset, BIT(desc->bit));
 
     return 0;
 }

[ ... ]

Quoted 4 lines
drivers/bluetooth/btqcomipc.c +0 -0
@@ -375,15 +376,16 @@ static int btss_recv_cust_frame(struct qcom_btss *desc, u8 cmd)
         WRITE_ONCE(desc->running, false);
         break;
     case IPC_CMD_START:

drivers/bluetooth/btqcomipc.c static int btss_recv_cust_frame(struct qcom_btss *desc, u8 cmd) · line 388

Quoted 10 lines
drivers/bluetooth/btqcomipc.c +0 -0
         spin_unlock(&desc->lock);
         ret = qcom_scm_pas_set_bluetooth_power_mode(BTSS_PAS_ID, false);
         spin_lock(&desc->lock);
         if (ret && ret != -EOPNOTSUPP) {
             bt_dev_err(desc->hdev,
                    "Failed to apply BTSS active power mode: %d",
                    ret);
             return ret;
         }
 

[Severity: High]
Does this code read total_size directly from shared memory without bounds checking?

Since this bypasses the validation in btss_worker(), could it result in desc->tx_ctxt pointing to unallocated memory if the firmware modifies it after initialization?

Quoted 3 lines
drivers/bluetooth/btqcomipc.c +0 -0
         desc->tx_ctxt = (struct context_info *)((void *)desc->rx_ctxt +
                 le16_to_cpu(desc->rx_ctxt->total_size));
         desc->lmsg_ctxt.widx = 0;

[ ... ]

drivers/bluetooth/btqcomipc.c static inline int btss_process_rx(struct qcom_btss *desc, · line 467

Quoted 9 lines
drivers/bluetooth/btqcomipc.c +0 -0
@@ -458,16 +460,25 @@ static inline int btss_process_rx(struct qcom_btss *desc,
     lring_buf = le32_to_cpu(desc->rx_ctxt->lring_buf);
     widx = READ_ONCE(rinfo->widx);
 
     while (ridx != widx) {
         struct ipc_aux_ptr aux_ptr = { };
 
         dma_rmb();
 

[Severity: Critical]
Are rinfo->rbuf and ridx validated against the bounds of the shared memory region before being used?

If the controller writes arbitrary offsets here, could TO_APPS_ADDR result in reading from or writing to arbitrary host kernel memory?

drivers/bluetooth/btqcomipc.c static inline int btss_process_rx(struct qcom_btss *desc, · line 468

Quoted 1 line
drivers/bluetooth/btqcomipc.c +0 -0
         rbuf = &((struct ring_buffer *)(TO_APPS_ADDR(le32_to_cpu(rinfo->rbuf))))[ridx];

[Severity: Medium]
Is it safe to directly dereference iomem-mapped memory pointers like rbuf->msg_hdr and rbuf->len without using the proper readw() or readl() I/O accessors?

Could this trigger alignment faults on certain architectures?

drivers/bluetooth/btqcomipc.c static inline int btss_process_rx(struct qcom_btss *desc,

Quoted 12 lines
drivers/bluetooth/btqcomipc.c +0 -0
         msg_hdr = le16_to_cpu(rbuf->msg_hdr);
         msg_len = le16_to_cpu(rbuf->len);
 
         if (!(msg_hdr & IPC_HDR_LONG_MSG) && msg_len > IPC_MSG_PLD_SZ) {
             desc->hdev->stat.err_rx++;
             bt_dev_err(desc->hdev,
                    "Dropping short RX frame with invalid len %u",
                    msg_len);
             goto continue_rx;
         }
 
         if (msg_hdr & IPC_HDR_LONG_MSG) {

[Severity: Critical]
Is there a risk of leaking arbitrary kernel memory here?

Since lmsg_data is read straight from the shared ring buffer, an attacker controlling the firmware could provide an arbitrary pointer that becomes converted to a host address via TO_APPS_ADDR.

Quoted 3 lines
             lmsg_data = le32_to_cpu(rbuf->payload.lmsg_data);
             rxbuf = TO_APPS_ADDR(lmsg_data);
             lsz = btss_lbuf_size(desc, desc->rx_ctxt);

[ ... ]

Quoted 9 lines
             /*
              * Check if the long message buffer extends past the end
              * of the ring buffer
              */
             if (msg_len > lring_end - lmsg_data) {
                 lbuf_idx = btss_get_buf_idx(desc->rx_ctxt,
                                 lmsg_data, lsz);
 
                 blks_consumed = desc->rx_ctxt->lmsg_buf_cnt - lbuf_idx;

[Severity: High]
Can this validation ever evaluate to true?

Based on the preceding checks, if msg_len > blks_consumed * lsz, then mathematically msg_len / lsz must be greater than or equal to blks_consumed.

Could a malformed msg_len completely bypass this check and cause an out-of-bounds memcpy_fromio()?

Quoted 5 lines
                 if (blks_consumed > msg_len / lsz) {
                     desc->hdev->stat.err_rx++;
                     bt_dev_err(desc->hdev,
                            "Dropping long RX frame with invalid length %u",
                            msg_len);
Quoted 9 lines
                     goto continue_rx;
                 }
                 aux_ptr.len = msg_len - (blks_consumed * lsz);
                 aux_ptr.buf = lring_buf;
             }
         } else {
             rxbuf = rbuf->payload.smsg_data;
         }

[Severity: Medium]
Will this overwrite the ack flag instead of accumulating it?

If an earlier message in the loop requested an ACK but the final message does not, will the hardware signaling loop silently drop the ACK request?

Quoted 3 lines
         *ack = msg_hdr & IPC_HDR_REQ_ACK;
 
         pkt_type = FIELD_GET(IPC_HDR_PKT_TYPE_MASK, msg_hdr);

[ ... ]

Quoted 1 line

continue_rx:

[Severity: High]
Does this modulo operation rely on rinfo->ring_buf_cnt being non-zero?

If the firmware modifies the count to zero in shared memory, could this cause a kernel panic via division-by-zero?

Quoted 6 lines
         ridx = (ridx + 1) % rinfo->ring_buf_cnt;
         rinfo->ridx = ridx;
 
         if (rx_count)
             (*rx_count)++;
     }

[ ... ]

drivers/bluetooth/btqcomipc.c static void btss_worker(struct work_struct *work) · line 532

Quoted 8 lines
drivers/bluetooth/btqcomipc.c +0 -0
@@ -515,16 +526,26 @@ static void btss_worker(struct work_struct *work)
     struct qcom_btss *desc = container_of(work, struct qcom_btss, work);
     struct ring_buffer_info *rinfo;
     bool ack = false;
     u32 offset, next;
     u16 total_size;
     int ret;
 

[Severity: High]
Could this lead to a deadlock?

The btss_worker runs in process context and acquires desc->lock without disabling softirqs. If a network softirq interrupts this CPU and calls btqcomipc_send() which uses spin_lock_irqsave(), will it spin forever waiting for this lock?

Quoted 10 lines
drivers/bluetooth/btqcomipc.c +0 -0
     spin_lock(&desc->lock);
 
     if (unlikely(!READ_ONCE(desc->running))) {
         /*
          * FW sets offset of RX context info at the start of the memory
          * region upon boot
          */
         offset = readl(desc->base);
         if (offset > desc->mem_size - sizeof(struct context_info)) {
             bt_dev_err(desc->hdev,

drivers/bluetooth/btqcomipc.c static void btss_worker(struct work_struct *work)

Quoted 10 lines
drivers/bluetooth/btqcomipc.c +0 -0
                    "Invalid offset after firmware boot: 0x%08x",
                    offset);
             goto spin_unlock;
         }
         dev_dbg(desc->dev, "offset after firmware boot: 0x%08x\n",
             offset);
 
         desc->rx_ctxt = (struct context_info *)(desc->base + offset);
 
         total_size = le16_to_cpu(desc->rx_ctxt->total_size);

[Severity: High]
Is this bounds check sufficient for the tx_ctxt pointer?

The check ensures rx_ctxt total_size is within mem_size, but tx_ctxt is later set to rx_ctxt + total_size. Should it also verify that there is enough room for the sizeof(struct context_info) of tx_ctxt itself at the end of the region?

Quoted 7 lines
         if (total_size < sizeof(struct context_info) ||
         total_size > desc->mem_size - offset) {
             bt_dev_err(desc->hdev, "Invalid total size: %u",
                    total_size);
             desc->rx_ctxt = NULL;
             goto spin_unlock;
         }

[ ... ]

Quoted 9 lines
     rinfo = &(desc->rx_ctxt->sring_buf_info);
     while (rinfo != NULL) {
         ret = btss_process_rx(desc, rinfo, &ack,
                       &desc->rx_ctxt->smsg_buf_cnt);
         if (ret) {
             bt_dev_err(desc->hdev,
                    "Failed to process peer msgs: %d", ret);
             goto spin_unlock;
         }

[Severity: High]
Could untrusted firmware hang the host CPU here?

The next pointer is read from shared memory. If the firmware intentionally creates a cycle in the linked list, will this while loop execute indefinitely and cause a Denial of Service?

Quoted 3 lines
         next = le32_to_cpu(rinfo->next);
         rinfo = next ? (struct ring_buffer_info *)TO_APPS_ADDR(next) : NULL;
     }

[ ... ]

Quoted 9 lines
drivers/bluetooth/btqcomipc.c +0 -0
@@ -661,16 +672,21 @@ static int btcomqipc_firmware_load(struct qcom_btss *desc)
             memcpy_toio(desc->base + phdr->p_vaddr,
                     seg_fw->data, phdr->p_filesz);
             if (phdr->p_memsz > phdr->p_filesz)
                 memset_io(desc->base + phdr->p_vaddr +
                       phdr->p_filesz, 0,
                       phdr->p_memsz - phdr->p_filesz);
 
 release_seg_fw:

drivers/bluetooth/btqcomipc.c static int btcomqipc_firmware_load(struct qcom_btss *desc)

Quoted 10 lines
drivers/bluetooth/btqcomipc.c +0 -0
             release_firmware(seg_fw);
 release_seg_name:
             kfree(seg_name);
             seg_name = NULL;
 
             if (ret)
                 goto release_fw;
         } else {
             memcpy_toio(desc->base + phdr->p_vaddr,
                     fw->data + phdr->p_offset, phdr->p_filesz);

[Severity: High]
Does this memset_io call lack a bounds check on phdr->p_memsz?

The earlier validation only ensures that p_filesz fits within desc->mem_size. If a malformed ELF file has a massive p_memsz, could this zero out kernel memory beyond the mapped desc->base region?

Quoted 5 lines
             if (phdr->p_memsz > phdr->p_filesz)
                 memset_io(desc->base + phdr->p_vaddr +
                       phdr->p_filesz, 0,
                       phdr->p_memsz - phdr->p_filesz);
         }

[ ... ]

drivers/bluetooth/btqcomipc.c static int btqcomipc_close(struct hci_dev *hdev) · line 758

Quoted 13 lines
drivers/bluetooth/btqcomipc.c +0 -0
@@ -731,16 +747,21 @@ static int btqcomipc_close(struct hci_dev *hdev)
     struct qcom_btss *desc = hci_get_drvdata(hdev);
     unsigned long flags;
     int ret;
 
     ret = qcom_scm_pas_shutdown(BTSS_PAS_ID);
     if (ret) {
         bt_dev_err(hdev, "Failed to stop firmware: %d", ret);
         return ret;
     }
 
     disable_irq(desc->irq);
 

[Severity: High]
Is it safe to shut down the physical IP without canceling the asynchronous worker first?

If btss_worker() is actively running and reading from desc->base, could powering down the controller via SCM cause a Synchronous External Abort or hardware fault before the running flag is set to false?

Quoted 3 lines
drivers/bluetooth/btqcomipc.c +0 -0
     spin_lock_irqsave(&desc->lock, flags);
     WRITE_ONCE(desc->running, false);
     spin_unlock_irqrestore(&desc->lock, flags);

[ ... ]

Quoted 5 lines
drivers/bluetooth/btqcomipc.c +0 -0
@@ -779,16 +800,21 @@ static int btqcomipc_send(struct hci_dev *hdev, struct sk_buff *skb)
     u16 hdr = FIELD_PREP(IPC_HDR_PKT_TYPE_MASK, IPC_HDR_PKT_TYPE_HCI);
     struct qcom_btss *desc = hci_get_drvdata(hdev);
     unsigned long flags;
     int ret;

drivers/bluetooth/btqcomipc.c static int btqcomipc_send(struct hci_dev *hdev, struct sk_buff *skb) · line 813

Quoted 10 lines
drivers/bluetooth/btqcomipc.c +0 -0
 
     spin_lock_irqsave(&desc->lock, flags);
 
     if (unlikely(!READ_ONCE(desc->running))) {
         bt_dev_err(hdev,
                "BTSS not initialized, failed to send message");
         ret = -ENODEV;
         goto spin_unlock;
     }
 

[Severity: Medium]
Will this bypass the FIFO order for HCI frames?

If a previous long frame failed to send and was queued to desc->tx_q via -EAGAIN, will attempting to send a new short frame directly leapfrog the backlog, causing silent protocol violations?

Quoted 4 lines
drivers/bluetooth/btqcomipc.c +0 -0
     ret = btss_send(desc, hdr, skb);
     if (ret) {
         if (ret == -EAGAIN) {
             if (skb_queue_len(&desc->tx_q) >= IPC_TX_QSIZE) {
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#11 lore raw

cover Bluetooth: btqcomipc: fixes on top of the IPQ5018 v5 series

In reply to George Moussalem

Hi George,

I brought your v5 up on a UniFi U6 Enterprise (IPQ5018) and needed these three changes on top of it for the controller to load its firmware, to survive an unbind/bind cycle and to take the board's address. They are against your v5 as posted; please fold whichever you agree with into v6.

1/3 keeps the dot in split firmware segment names (qca/bt_fw_patch.b02). 2/3 deasserts the BTSS reset before enabling the LPO clock; a probe after
an unbind otherwise fails with "gcc_btss_lpo_clk status stuck at 'off'".
3/3 sets HCI_QUIRK_USE_BDADDR_PROPERTY: btqca skips the NVM tag parsing on
IPQ5018, so the placeholder address (50:18:00:00:5a:ad) is never detected and every board comes up with it.

Three notes on v5 itself:
- Unloading the module (rmmod btqcomipc) with the controller up hangs the SoC until the watchdog resets it; I have not looked into why.
- It uses HCI_QUIRK_USE_BDADDR_NVMEM and HCI_QUIRK_BDADDR_NVMEM_BE, which come from a separate series that is not in bluetooth-next or next-20261009, so v5 does not build on its own.
- Its btqca patch no longer applies to next-20261009 (btqca.c moved on).

3/3 works best with "Bluetooth: hci_core: program a public address set during auto off", sent separately to linux-bluetooth: without it, setting the address within two seconds of the index appearing leaves the controller up but invisible to mgmt.

Transparency note: developed with an LLM coding assistant (Claude), which traced these while bringing up the board and wrote the changes and these messages. Tested on the U6 Enterprise with Linux 7.2.8 and BlueZ: the firmware loads, hci0 stays unconfigured until userspace sets the address, then scans and advertises. A W=1 arm64 build of drivers/bluetooth is clean.

Andrei-Alexandru Bleortu (3):
Bluetooth: btqcomipc: keep the dot in split firmware segment names
Bluetooth: btqcomipc: deassert the BTSS reset before enabling its clock
Bluetooth: btqcomipc: take the board's address from the host

 drivers/bluetooth/btqcomipc.c | 24 +++++++++++++++---------
 1 file changed, 16 insertions(+), 8 deletions(-)
Signature · 1 line
2.47.3
#12 lore raw

PATCH 1/3 Bluetooth: btqcomipc: keep the dot in split firmware segment names

The segment files of a split image are named <stem>.bNN, as qcom_mdt_loader expects, but the stem excludes the dot, so the driver asked for qca/bt_fw_patchb02 instead of qca/bt_fw_patch.b02 and failed to load any firmware split across segment files.

---
 drivers/bluetooth/btqcomipc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bluetooth/btqcomipc.c +1 -1
index 9e56d1c8e..21dd3e812 100644
@@ -847,7 +847,7 @@ static int btcomqipc_firmware_load(struct qcom_btss *desc)
 		/* Check if firmware is split across multiple segment files */
 		if (phdr->p_offset > fw->size ||
 		    phdr->p_filesz > fw->size - phdr->p_offset) {
-			seg_name = kasprintf(GFP_KERNEL, "%.*sb%02d",
+			seg_name = kasprintf(GFP_KERNEL, "%.*s.b%02d",
 					     (int)stem_len, desc->firmware, i);
 			if (!seg_name) {
 				ret = -ENOMEM;
#13 lore raw

RE: Bluetooth: btqcomipc: fixes on top of the IPQ5018 v5 series

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----

error: drivers/bluetooth/btqcomipc.c: does not exist in index
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"

Please resolve the issue and submit the patches again.

---
Regards,
Linux Bluetooth

#14 lore raw

PATCH 2/3 Bluetooth: btqcomipc: deassert the BTSS reset before enabling its clock

In reply to Andrei-Alexandru Bleortu

An unbind asserts the BTSS reset through devres, and a later probe then enabled the LPO branch clock with the subsystem still in reset:
"gcc_btss_lpo_clk status stuck at 'off'" and the probe failed with -EBUSY. Deassert the reset first; devres then also undoes them in the right order (clock off, then reset).

---
 drivers/bluetooth/btqcomipc.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/bluetooth/btqcomipc.c +9 -5
index 21dd3e812..8513c1780 100644
@@ -1147,16 +1147,20 @@ static int btqcomipc_probe(struct platform_device *pdev)
 
 	of_node_put(ipc_np);
 
-	lpo_clk = devm_clk_get_enabled(dev, "lpo");
-	if (IS_ERR(lpo_clk))
-		return dev_err_probe(dev, PTR_ERR(lpo_clk),
-				     "Failed to get lpo clock\n");
-
+	/*
+	 * The LPO branch clock cannot turn on while the subsystem is held
+	 * in reset, which is how an unbind leaves it: deassert first.
+	 */
 	btss_reset = devm_reset_control_get_exclusive_deasserted(dev, NULL);
 	if (IS_ERR_OR_NULL(btss_reset))
 		return dev_err_probe(dev, PTR_ERR(btss_reset),
 				     "unable to deassert reset\n");
 
+	lpo_clk = devm_clk_get_enabled(dev, "lpo");
+	if (IS_ERR(lpo_clk))
+		return dev_err_probe(dev, PTR_ERR(lpo_clk),
+				     "Failed to get lpo clock\n");
+
 	desc->irq = platform_get_irq(pdev, 0);
 	if (desc->irq < 0)
 		return dev_err_probe(dev, desc->irq, "Failed to acquire IRQ\n");
#15 lore raw

PATCH 3/3 Bluetooth: btqcomipc: take the board's address from the host

In reply to Andrei-Alexandru Bleortu

The IPQ5018 NVM carries one placeholder address (50:18:00:00:5a:ad) for every board, and btqca skips the NVM tag parsing on IPQ5018, so the placeholder check that sets HCI_QUIRK_USE_BDADDR_PROPERTY for other QCA parts never matches: the controller came up configured with the placeholder and, being set up again on every power on, went back to it even after an address was set through mgmt.

Set the quirk in setup, so the controller stays unconfigured until the board's address comes from the local-bd-address property or from userspace, and the core programs it after each setup.

---
 drivers/bluetooth/btqcomipc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/bluetooth/btqcomipc.c +6 -2
index 8513c1780..92a0d671e 100644
@@ -997,9 +997,13 @@ static int btqcomipc_setup(struct hci_dev *hdev)
 	}
 
 	/*
-	 * 7.2 has no NVMEM-backed BD address in the HCI core; the board's
-	 * address is set from userspace through set_bdaddr instead.
+	 * The NVM carries the same placeholder address for every board, so
+	 * the controller stays unconfigured until the board's address comes
+	 * from the local-bd-address property or from userspace, and the core
+	 * programs it again after each setup.
 	 */
+	hci_set_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY);
+
 	return 0;
 }
 
#16 lore raw

PATCH v5 5/6 arm64: dts: qcom: ipq5018: add node required for Bluetooth support

In reply to George Moussalem

Add node to enable Bluetooth support on the IPQ5018 platform.

---
 arch/arm64/boot/dts/qcom/ipq5018.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/qcom/ipq5018.dtsi +16 -0
index 6f8004a22a1f..8c252fa3ff5b 100644
@@ -453,6 +453,22 @@ tcsr: syscon@1937000 {
 			reg = <0x01937000 0x21000>;
 		};
 
+		bluetooth: bluetooth@7000000 {
+			compatible = "qcom,ipq5018-bt";
+			reg = <0x07000000 0x58000>;
+
+			firmware-name = "qca/bt_fw_patch.mbn";
+
+			clocks = <&gcc GCC_BTSS_LPO_CLK>;
+			clock-names = "lpo";
+			resets = <&gcc GCC_BTSS_BCR>;
+
+			qcom,ipc = <&apcs_glb 8 23>;
+			interrupts = <GIC_SPI 162 IRQ_TYPE_EDGE_RISING>;
+
+			status = "disabled";
+		};
+
 		sdhc_1: mmc@7804000 {
 			compatible = "qcom,ipq5018-sdhci", "qcom,sdhci-msm-v5";
 			reg = <0x7804000 0x1000>;
Signature · 1 line
2.53.0
#17 lore raw

Re: [PATCH v5 5/6] arm64: dts: qcom: ipq5018: add node required for Bluetooth support

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] Out-of-bounds write in `memset_io` during firmware ELF loading. - [High] Unvalidated…

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Out-of-bounds write in memset_io during firmware ELF loading.
- [High] Unvalidated hardware/firmware inputs from shared memory lead to division-by-zero panics and out-of-bounds accesses.
- [High] Direct pointer dereferences to I/O memory without using proper I/O accessors, leading to potential alignment faults.
- [High] Incorrect teardown sequence in btqcomipc_close causing a race condition and unrecoverable bus faults. --

--- Patch [5]: [PATCH v5 5/6] arm64: dts: qcom: ipq5018: add node required for Bluetooth support --- commit 30194f675ebc660c7f509c3ca16e858f9db019e2
Author: George Moussalem <[email protected]>
Subject: arm64: dts: qcom: ipq5018: add node required for Bluetooth support

This commit adds a device tree node to enable Bluetooth support on the IPQ5018 platform. It sets up the bluetooth node with the appropriate register space, firmware name, clocks, resets, and interrupts.

Quoted 17 lines
arch/arm64/boot/dts/qcom/ipq5018.dtsi +9 -0
index 6f8004a22a1ff..8c252fa3ff5bf 100644
@@ -453,6 +453,22 @@ tcsr: syscon@1937000 {
 			reg = <0x01937000 0x21000>;
 		};
 
+		bluetooth: bluetooth@7000000 {
+			compatible = "qcom,ipq5018-bt";
+			reg = <0x07000000 0x58000>;
+
+			firmware-name = "qca/bt_fw_patch.mbn";
+
+			clocks = <&gcc GCC_BTSS_LPO_CLK>;
+			clock-names = "lpo";
+			resets = <&gcc GCC_BTSS_BCR>;

arch/arm64/boot/dts/qcom/ipq5018.dtsi tcsr: syscon@1937000 { · line 474

Quoted 10 lines
arch/arm64/boot/dts/qcom/ipq5018.dtsi +7 -0
+
+			qcom,ipc = <&apcs_glb 8 23>;
+			interrupts = <GIC_SPI 162 IRQ_TYPE_EDGE_RISING>;
+
+			status = "disabled";
+		};
+
 		sdhc_1: mmc@7804000 {
 			compatible = "qcom,ipq5018-sdhci", "qcom,sdhci-msm-v5";
 			reg = <0x7804000 0x1000>;

While reviewing the driver code associated with this hardware, a few questions came up regarding the implementation in drivers/bluetooth/btqcomipc.c.

drivers/bluetooth/btqcomipc.c:btcomqipc_firmware_load() {
...

			if (phdr->p_memsz > phdr->p_filesz)
				memset_io(desc->base + phdr->p_vaddr +
					  phdr->p_filesz, 0,
					  phdr->p_memsz - phdr->p_filesz);

...
}

[Severity: High]
Can this lead to an out-of-bounds I/O memory write?

When the firmware ELF is parsed in btcomqipc_firmware_load(), it appears we validate that phdr->p_filesz fits within the allocated IO memory, but is there a similar check for phdr->p_memsz?

If a malformed firmware image provides an arbitrarily large p_memsz, could this memset_io() write zeroes out-of-bounds past the end of the desc->base mapping?

drivers/bluetooth/btqcomipc.c:btss_process_rx() {
...

		ridx = (ridx + 1) % rinfo->ring_buf_cnt;
		rinfo->ridx = ridx;

...
}

drivers/bluetooth/btqcomipc.c:btss_get_tx_rbuf() {
...

		idx = (rinfo->widx + 1) % (desc->tx_ctxt->smsg_buf_cnt);

...
}

[Severity: High]
Could these modulo operations cause a division-by-zero panic?

The firmware running on the Bluetooth controller populates the context_info and ring_buffer_info structures in shared memory. If the firmware sets rinfo->ring_buf_cnt or desc->tx_ctxt->smsg_buf_cnt to 0, could the kernel crash here?

Additionally, are offsets like rinfo->rbuf checked against desc->mem_size to prevent out-of-bounds I/O memory accesses?

drivers/bluetooth/btqcomipc.c:btss_process_rx() {
...

		msg_hdr = le16_to_cpu(rbuf->msg_hdr);
		msg_len = le16_to_cpu(rbuf->len);

...
}

drivers/bluetooth/btqcomipc.c:btss_send() {
...

	rbuf->msg_hdr = cpu_to_le16(hdr);
	rbuf->len = cpu_to_le16(len);

...
}

drivers/bluetooth/btqcomipc.c:btss_worker() {
...

		total_size = le16_to_cpu(desc->rx_ctxt->total_size);

...
}

[Severity: High]
Does this code perform direct pointer dereferences to I/O memory without using proper I/O accessors?

The memory mapped via devm_platform_get_and_ioremap_resource() is Device memory on ARM64. Since the driver drops the __iomem annotation and accesses packed structures using direct C pointer assignments, could the compiler emit unaligned load/store instructions?

Executing these instructions against ARM64 Device memory violates architectural rules and could trigger an alignment fault.

drivers/bluetooth/btqcomipc.c:btqcomipc_close() {
...

	ret = qcom_scm_pas_shutdown(BTSS_PAS_ID);
	if (ret) {
		bt_dev_err(hdev, "Failed to stop firmware: %d", ret);
		return ret;
	}

	disable_irq(desc->irq);

	spin_lock_irqsave(&desc->lock, flags);
	WRITE_ONCE(desc->running, false);

...
}

[Severity: High]
Is the teardown sequence in btqcomipc_close() safe from race conditions?

The driver calls qcom_scm_pas_shutdown() to power down the Bluetooth subsystem before disabling the interrupt, setting desc->running = false, and flushing the workqueue.

If an interrupt fires during or immediately after shutdown, or if btss_worker is already running concurrently, could the worker attempt to read from or write to the BTSS memory-mapped I/O registers? Accessing a powered-off peripheral's registers typically results in a fatal bus error.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Reviewed-by on v5 5/6
#18 lore raw

Re: [PATCH v5 5/6] arm64: dts: qcom: ipq5018: add node required for Bluetooth support

In reply to George Moussalem
Quoted 22 lines · On 7/9/26 11:18 AM, George Moussalem via B4 Relay wrote:

From: George Moussalem <[email protected]>

Add node to enable Bluetooth support on the IPQ5018 platform.

---
 arch/arm64/boot/dts/qcom/ipq5018.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/qcom/ipq5018.dtsi +4 -0
index 6f8004a22a1f..8c252fa3ff5b 100644
@@ -453,6 +453,22 @@ tcsr: syscon@1937000 {
 			reg = <0x01937000 0x21000>;
 		};
 
+		bluetooth: bluetooth@7000000 {
+			compatible = "qcom,ipq5018-bt";
+			reg = <0x07000000 0x58000>;
+

arch/arm64/boot/dts/qcom/ipq5018.dtsi tcsr: syscon@1937000 { · line 469

Quoted 10 lines
arch/arm64/boot/dts/qcom/ipq5018.dtsi +10 -0
+			firmware-name = "qca/bt_fw_patch.mbn";
+
+			clocks = <&gcc GCC_BTSS_LPO_CLK>;
+			clock-names = "lpo";
+			resets = <&gcc GCC_BTSS_BCR>;
+
+			qcom,ipc = <&apcs_glb 8 23>;
+			interrupts = <GIC_SPI 162 IRQ_TYPE_EDGE_RISING>;
+
+			status = "disabled";

Since the firmware is unsigned, I think it could make sense to enable this by default

any which way

Konrad

#19 lore raw

Re: [PATCH v5 5/6] arm64: dts: qcom: ipq5018: add node required for Bluetooth support

Quoted 37 lines · Konrad Dybcio
Quoted 22 lines · On 7/9/26 11:18 AM, George Moussalem via B4 Relay wrote:

From: George Moussalem <[email protected]>

Add node to enable Bluetooth support on the IPQ5018 platform.

---
 arch/arm64/boot/dts/qcom/ipq5018.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/qcom/ipq5018.dtsi +4 -0
index 6f8004a22a1f..8c252fa3ff5b 100644
@@ -453,6 +453,22 @@ tcsr: syscon@1937000 {
 			reg = <0x01937000 0x21000>;
 		};
 
+		bluetooth: bluetooth@7000000 {
+			compatible = "qcom,ipq5018-bt";
+			reg = <0x07000000 0x58000>;
+

arch/arm64/boot/dts/qcom/ipq5018.dtsi tcsr: syscon@1937000 { · line 469

Quoted 10 lines
arch/arm64/boot/dts/qcom/ipq5018.dtsi +10 -0
+			firmware-name = "qca/bt_fw_patch.mbn";
+
+			clocks = <&gcc GCC_BTSS_LPO_CLK>;
+			clock-names = "lpo";
+			resets = <&gcc GCC_BTSS_BCR>;
+
+			qcom,ipc = <&apcs_glb 8 23>;
+			interrupts = <GIC_SPI 162 IRQ_TYPE_EDGE_RISING>;
+
+			status = "disabled";

Since the firmware is unsigned, I think it could make sense to enable this by default

Quoted 1 line

any which way

I've found that the controller is not wired up on all ipq5018 boards. For ex. Linksys router boards have it enabled and wired up by default while you can enable the controller on some Xiaomi and Gl.Inet boards but the controller isn't connected to anything.

Quoted 4 lines

Konrad

George

#20 lore raw

Re: [PATCH v5 5/6] arm64: dts: qcom: ipq5018: add node required for Bluetooth support

In reply to George Moussalem
Quoted 15 lines · On 7/9/26 11:18 AM, George Moussalem via B4 Relay wrote:

From: George Moussalem <[email protected]>

Add node to enable Bluetooth support on the IPQ5018 platform.

---
 arch/arm64/boot/dts/qcom/ipq5018.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/qcom/ipq5018.dtsi +0 -0
index 6f8004a22a1f..8c252fa3ff5b 100644

arch/arm64/boot/dts/qcom/ipq5018.dtsi tcsr: syscon@1937000 { · line 460

Quoted 8 lines
arch/arm64/boot/dts/qcom/ipq5018.dtsi +5 -0
@@ -453,6 +453,22 @@ tcsr: syscon@1937000 {
 			reg = <0x01937000 0x21000>;
 		};
 
+		bluetooth: bluetooth@7000000 {
+			compatible = "qcom,ipq5018-bt";
+			reg = <0x07000000 0x58000>;
+
+			firmware-name = "qca/bt_fw_patch.mbn";

Hm, rethinking this, it must have ipq5018 somewhere in the name

Konrad

#21 lore raw

Re: [PATCH v5 5/6] arm64: dts: qcom: ipq5018: add node required for Bluetooth support

Quoted 19 lines · Konrad Dybcio
Quoted 18 lines · On 7/9/26 11:18 AM, George Moussalem via B4 Relay wrote:

From: George Moussalem <[email protected]>

Add node to enable Bluetooth support on the IPQ5018 platform.

---
 arch/arm64/boot/dts/qcom/ipq5018.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/qcom/ipq5018.dtsi +0 -0
index 6f8004a22a1f..8c252fa3ff5b 100644
@@ -453,6 +453,22 @@ tcsr: syscon@1937000 {
 			reg = <0x01937000 0x21000>;
 		};
 
Quoted 7 lines

arch/arm64/boot/dts/qcom/ipq5018.dtsi tcsr: syscon@1937000 { · line 460

Quoted 5 lines
arch/arm64/boot/dts/qcom/ipq5018.dtsi +5 -0
+		bluetooth: bluetooth@7000000 {
+			compatible = "qcom,ipq5018-bt";
+			reg = <0x07000000 0x58000>;
+
+			firmware-name = "qca/bt_fw_patch.mbn";

Hm, rethinking this, it must have ipq5018 somewhere in the name

I agree but all QCA BT firmware and rampatches are published in the /lib/firmware/qca directory, see:
https://git.kernel.org/pub/scm/linux/kernel/git/ath/linux-firmware.git/tree/qca

Quoted 2 lines

Konrad

George

#22 lore raw

Re: [PATCH v5 5/6] arm64: dts: qcom: ipq5018: add node required for Bluetooth support

Quoted 28 lines · George Moussalem
Quoted 19 lines · Konrad Dybcio
Quoted 18 lines · On 7/9/26 11:18 AM, George Moussalem via B4 Relay wrote:

From: George Moussalem <[email protected]>

Add node to enable Bluetooth support on the IPQ5018 platform.

---
 arch/arm64/boot/dts/qcom/ipq5018.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/qcom/ipq5018.dtsi +0 -0
index 6f8004a22a1f..8c252fa3ff5b 100644
@@ -453,6 +453,22 @@ tcsr: syscon@1937000 {
 			reg = <0x01937000 0x21000>;
 		};
 
Quoted 7 lines

arch/arm64/boot/dts/qcom/ipq5018.dtsi tcsr: syscon@1937000 { · line 460

Quoted 5 lines
arch/arm64/boot/dts/qcom/ipq5018.dtsi +5 -0
+		bluetooth: bluetooth@7000000 {
+			compatible = "qcom,ipq5018-bt";
+			reg = <0x07000000 0x58000>;
+
+			firmware-name = "qca/bt_fw_patch.mbn";

Hm, rethinking this, it must have ipq5018 somewhere in the name

Quoted 3 lines

I agree but all QCA BT firmware and rampatches are published in the /lib/firmware/qca directory, see:
https://git.kernel.org/pub/scm/linux/kernel/git/ath/linux-firmware.git/tree/qca

+Jeff, Bartosz?

Konrad

#23 lore raw

Re: [PATCH v5 5/6] arm64: dts: qcom: ipq5018: add node required for Bluetooth support

Quoted 29 lines · Konrad Dybcio
Quoted 28 lines · George Moussalem
Quoted 26 lines · Konrad Dybcio
Quoted 15 lines · On 7/9/26 11:18 AM, George Moussalem via B4 Relay wrote:

From: George Moussalem <[email protected]>

Add node to enable Bluetooth support on the IPQ5018 platform.

---
 arch/arm64/boot/dts/qcom/ipq5018.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/qcom/ipq5018.dtsi +0 -0
index 6f8004a22a1f..8c252fa3ff5b 100644

arch/arm64/boot/dts/qcom/ipq5018.dtsi tcsr: syscon@1937000 { · line 460

Quoted 8 lines
arch/arm64/boot/dts/qcom/ipq5018.dtsi +5 -0
@@ -453,6 +453,22 @@ tcsr: syscon@1937000 {
 			reg = <0x01937000 0x21000>;
 		};
 
+		bluetooth: bluetooth@7000000 {
+			compatible = "qcom,ipq5018-bt";
+			reg = <0x07000000 0x58000>;
+
+			firmware-name = "qca/bt_fw_patch.mbn";

Hm, rethinking this, it must have ipq5018 somewhere in the name

Quoted 6 lines
Quoted 3 lines

I agree but all QCA BT firmware and rampatches are published in the /lib/firmware/qca directory, see:
https://git.kernel.org/pub/scm/linux/kernel/git/ath/linux-firmware.git/tree/qca

+Jeff, Bartosz?

I'm not sure what the question is. This particular blob doesn't seem to exist anywhere in linux-firmware yet. I agree, ideally the platform name should be in the firmware name so let's upstream it to linux-firmware as such? Am I missing something?

Bartosz

#24 lore raw

Re: [PATCH v5 5/6] arm64: dts: qcom: ipq5018: add node required for Bluetooth support

Quoted 35 lines · Bartosz Golaszewski
Quoted 33 lines · Konrad Dybcio
Quoted 31 lines · George Moussalem
Quoted 19 lines · Konrad Dybcio
Quoted 18 lines · On 7/9/26 11:18 AM, George Moussalem via B4 Relay wrote:

From: George Moussalem <[email protected]>

Add node to enable Bluetooth support on the IPQ5018 platform.

---
 arch/arm64/boot/dts/qcom/ipq5018.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/qcom/ipq5018.dtsi +0 -0
index 6f8004a22a1f..8c252fa3ff5b 100644
@@ -453,6 +453,22 @@ tcsr: syscon@1937000 {
 			reg = <0x01937000 0x21000>;
 		};
 
Quoted 7 lines

arch/arm64/boot/dts/qcom/ipq5018.dtsi tcsr: syscon@1937000 { · line 460

Quoted 5 lines
arch/arm64/boot/dts/qcom/ipq5018.dtsi +5 -0
+		bluetooth: bluetooth@7000000 {
+			compatible = "qcom,ipq5018-bt";
+			reg = <0x07000000 0x58000>;
+
+			firmware-name = "qca/bt_fw_patch.mbn";

Hm, rethinking this, it must have ipq5018 somewhere in the name

I agree but all QCA BT firmware and rampatches are published in the /lib/firmware/qca directory, see:
https://git.kernel.org/pub/scm/linux/kernel/git/ath/linux-firmware.git/tree/qca

Quoted 7 lines
Quoted 2 lines

+Jeff, Bartosz?

I'm not sure what the question is. This particular blob doesn't seem to exist anywhere in linux-firmware yet. I agree, ideally the platform name should be in the firmware name so let's upstream it to linux-firmware as such? Am I missing something?

That's what I'd like to happen - just wanted to make sure you're in the loop, so that a platform-specific MBN doesn't end up with such a generic name in case that was the plan.

Konrad

#25 lore raw

Re: [PATCH v5 5/6] arm64: dts: qcom: ipq5018: add node required for Bluetooth support

Quoted 39 lines · Konrad Dybcio
Quoted 38 lines · Bartosz Golaszewski
Quoted 35 lines · Konrad Dybcio
Quoted 28 lines · George Moussalem
Quoted 19 lines · Konrad Dybcio
Quoted 18 lines · On 7/9/26 11:18 AM, George Moussalem via B4 Relay wrote:

From: George Moussalem <[email protected]>

Add node to enable Bluetooth support on the IPQ5018 platform.

---
 arch/arm64/boot/dts/qcom/ipq5018.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/qcom/ipq5018.dtsi +0 -0
index 6f8004a22a1f..8c252fa3ff5b 100644
@@ -453,6 +453,22 @@ tcsr: syscon@1937000 {
 			reg = <0x01937000 0x21000>;
 		};
 
Quoted 7 lines

arch/arm64/boot/dts/qcom/ipq5018.dtsi tcsr: syscon@1937000 { · line 460

Quoted 5 lines
arch/arm64/boot/dts/qcom/ipq5018.dtsi +5 -0
+		bluetooth: bluetooth@7000000 {
+			compatible = "qcom,ipq5018-bt";
+			reg = <0x07000000 0x58000>;
+
+			firmware-name = "qca/bt_fw_patch.mbn";

Hm, rethinking this, it must have ipq5018 somewhere in the name

Quoted 3 lines

I agree but all QCA BT firmware and rampatches are published in the /lib/firmware/qca directory, see:
https://git.kernel.org/pub/scm/linux/kernel/git/ath/linux-firmware.git/tree/qca

+Jeff, Bartosz?

Quoted 8 lines
Quoted 4 lines

I'm not sure what the question is. This particular blob doesn't seem to exist anywhere in linux-firmware yet. I agree, ideally the platform name should be in the firmware name so let's upstream it to linux-firmware as such? Am I missing something?

That's what I'd like to happen - just wanted to make sure you're in the loop, so that a platform-specific MBN doesn't end up with such a generic name in case that was the plan.

Perfect, kindly let me know what the name of the MBN that will be upstreamed to linux-firmware will be and I'll adjust the name in the next version. The current name was taken as-is from firmware images distributed to vendors and as available in code.qualcomm.com.

If it will be provided as MBN format, shall I remove support for loading MDT in the driver or leave as is?

Quoted 2 lines

Konrad

George

#26 lore raw

PATCH v5 6/6 MAINTAINERS: Add IPQ5018 driver to Qualcomm Bluetooth driver entry

In reply to George Moussalem

Add the Qualcomm IPQ5018 Bluetooth driver to the existing entry for Qualcomm Bluetooth drivers.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index eb8cdcc76324..33dd0c70c277 100644
@@ -21876,6 +21876,7 @@ L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/net/bluetooth/qcom,*
 F:	drivers/bluetooth/btqca.[ch]
+F:	drivers/bluetooth/btqcomipc.c
 F:	drivers/bluetooth/btqcomsmd.c
 F:	drivers/bluetooth/hci_qca.c
 
Signature · 1 line
2.53.0