From: Chris Lu <chris.lu@mediatek.com>
To: Marcel Holtmann <marcel@holtmann.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
Luiz Von Dentz <luiz.dentz@gmail.com>
Cc: Sean Wang <sean.wang@mediatek.com>,
Will Lee <will-cy.Lee@mediatek.com>, SS Wu <ss.wu@mediatek.com>,
Steve Lee <steve.lee@mediatek.com>,
linux-bluetooth <linux-bluetooth@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-mediatek <linux-mediatek@lists.infradead.org>,
Paul Menzel <pmenzel@molgen.mpg.de>,
Chris Lu <chris.lu@mediatek.com>
Subject: [PATCH v8 0/5] Bluetooth: btmtk: Add MT7928 support
Date: Thu, 2 Jul 2026 15:28:35 +0800 [thread overview]
Message-ID: <20260702072840.1712057-1-chris.lu@mediatek.com> (raw)
This patch series adds support for MT7928 (device ID 0x7935) to the
btmtk driver, which requires a new two-stage firmware loading process
with CBMCU firmware.
The series is organized to fix existing issues first, then improve code
quality, and finally add new functionality:
Patch 1 fixes a pre-existing security issue in btmtk_setup_firmware_79xx()
by adding comprehensive firmware size validation to prevent out-of-bounds
memory access with truncated or malicious firmware files.
Patch 2 fixes a regression introduced in commit 28b7c5a6db74
("Bluetooth: btmtk: Add MT6639 (MT7927) Bluetooth support") where
SDIO devices would incorrectly log "BT HW ver: 0x0000" due to
hardcoded dev_id=0.
The fix passes the device ID read from hardware register (0x70010200) to
mt79xx_setup(), ensuring SDIO devices display the correct chip ID, matching
the USB driver behavior.
Patch 3 refactors existing firmware download code by replacing magic
numbers with a descriptive BTMTK_WMT_PKT_* enum, making the packet
sequencing logic clearer.
Patch 4 improves BT firmware logging to provide more useful information
for debugging: adds firmware filename before loading and displays chip ID
as HW version instead of firmware's hwver field.
Patch 5 implements MT7928 firmware download flow, which requires loading
CBMCU firmware before Bluetooth firmware. The CBMCU firmware uses a
two-phase download sequence: Phase 1 downloads the section containing
global descriptor and signature data, Phase 2 downloads the remaining
firmware sections.
Tested on MT7928 hardware with successful firmware loading and
Bluetooth functionality verification.
Changes in v8:
- Add Patch 1 to fix firmware size validation in
btmtk_setup_firmware_79xx()
- Add Patch 2 to fix SDIO device logging regression
SDIO devices were passing hardcoded 0, causing "BT HW ver: 0x0000" log
Changes in v7:
- Patch 3 (was Patch 1): Extend magic number refactoring to
btmtk_setup_firmware() in addition to btmtk_setup_firmware_79xx() for
consistency
- Patch 4 (was Patch 2): Fix potential buffer over-read by
using %.16s format specifier for hdr->datetime which is a 16-byte
array that may not be null-terminated
- Patch 5 (was Patch 3): Apply same %.16s fix to CBMCU firmware logging
Changes in v6:
- Fix timeout handling in btmtk_cbmcu_patch_status() to return -ETIMEDOUT
instead of success when polling exhausts retry count
- Add integer overflow protection in btmtk_load_cbmcu_firmware() using
check_mul_overflow() and check_add_overflow()
Changes in v5:
- Split into three patches: refactoring, logging improvement, and
new feature
- Add Patch 2 to improve BT firmware logging independently
- Apply same logging improvements to CBMCU firmware in Patch 3
Changes in v4:
- Split into two patches: refactoring and new feature
- Add BTMTK_WMT_PKT_* enum to improve code readability
- Replace magic numbers (0xF0, 0xF1) with descriptive macros
Changes in v3:
- Add firmware size validation with bounds checking
- Improve error messages with context information
Changes in v2:
- Simplified enum usage by consolidating status definitions
Chris Lu (5):
Bluetooth: btmtk: Add firmware size validation in
btmtk_setup_firmware_79xx()
Bluetooth: btmtksdio: Pass hardware dev_id to mt79xx_setup()
Bluetooth: btmtk: Replace magic numbers with WMT packet flag enum
Bluetooth: btmtk: Improve BT firmware logging
Bluetooth: btmtk: Add MT7928 support
drivers/bluetooth/btmtk.c | 427 +++++++++++++++++++++++++++++++++-
drivers/bluetooth/btmtk.h | 9 +
drivers/bluetooth/btmtksdio.c | 6 +-
3 files changed, 430 insertions(+), 12 deletions(-)
--
2.45.2
next reply other threads:[~2026-07-02 7:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 7:28 Chris Lu [this message]
2026-07-02 7:28 ` [PATCH v8 1/5] Bluetooth: btmtk: Add firmware size validation in btmtk_setup_firmware_79xx() Chris Lu
2026-07-02 8:21 ` Bluetooth: btmtk: Add MT7928 support bluez.test.bot
2026-07-02 7:28 ` [PATCH v8 2/5] Bluetooth: btmtksdio: Pass hardware dev_id to mt79xx_setup() Chris Lu
2026-07-02 7:28 ` [PATCH v8 3/5] Bluetooth: btmtk: Replace magic numbers with WMT packet flag enum Chris Lu
2026-07-02 7:28 ` [PATCH v8 4/5] Bluetooth: btmtk: Improve BT firmware logging Chris Lu
2026-07-02 7:28 ` [PATCH v8 5/5] Bluetooth: btmtk: Add MT7928 support Chris Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260702072840.1712057-1-chris.lu@mediatek.com \
--to=chris.lu@mediatek.com \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=pmenzel@molgen.mpg.de \
--cc=sean.wang@mediatek.com \
--cc=ss.wu@mediatek.com \
--cc=steve.lee@mediatek.com \
--cc=will-cy.Lee@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.