public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Sean Wang <sean.wang@mediatek.com>,
	Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
	Sasha Levin <sashal@kernel.org>,
	marcel@holtmann.org, luiz.dentz@gmail.com,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 7.0-6.12] Bluetooth: btusb: Add new VID/PID 13d3/3579 for MT7902
Date: Mon, 20 Apr 2026 09:16:57 -0400	[thread overview]
Message-ID: <20260420132314.1023554-23-sashal@kernel.org> (raw)
In-Reply-To: <20260420132314.1023554-1-sashal@kernel.org>

From: Sean Wang <sean.wang@mediatek.com>

[ Upstream commit 51c4173b89fe7399bad1381016096cc154588660 ]

Add VID 13d3 & PID 3579 for MediaTek MT7902 USB Bluetooth chip.

The information in /sys/kernel/debug/usb/devices about the Bluetooth
device is listed as the below.

T:  Bus=01 Lev=01 Prnt=01 Port=09 Cnt=04 Dev#=  7 Spd=480  MxCh= 0
D:  Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=13d3 ProdID=3579 Rev= 1.00
S:  Manufacturer=MediaTek Inc.
S:  Product=Wireless_Device
S:  SerialNumber=000000000
C:* #Ifs= 3 Cfg#= 1 Atr=e0 MxPwr=100mA
A:  FirstIf#= 0 IfCount= 3 Cls=e0(wlcon) Sub=01 Prot=01
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=125us
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
I:  If#= 1 Alt= 6 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  63 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  63 Ivl=1ms
I:  If#= 2 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=8a(I) Atr=03(Int.) MxPS=  64 Ivl=125us
E:  Ad=0a(O) Atr=03(Int.) MxPS=  64 Ivl=125us
I:* If#= 2 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=8a(I) Atr=03(Int.) MxPS= 512 Ivl=125us
E:  Ad=0a(O) Atr=03(Int.) MxPS= 512 Ivl=125us

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

Now I have all the information needed for the full analysis. Let me
compile the results.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: Subject Line**
Record: [Bluetooth: btusb] [Add] Adding new USB VID/PID 13d3/3579 for
MediaTek MT7902 Bluetooth chip.

**Step 1.2: Tags**
- Signed-off-by: Sean Wang <sean.wang@mediatek.com> (author, MediaTek
  Bluetooth developer)
- Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  (Bluetooth subsystem maintainer)
- No Fixes: tag (expected for device ID additions)
- No Cc: stable (expected for commits under review)
- No Reported-by (but user interest is documented on the mailing list)

**Step 1.3: Body Text**
The commit message describes adding a new USB VID/PID pair for the
MT7902 Bluetooth chip. It includes full USB device descriptor
information from `/sys/kernel/debug/usb/devices`, confirming this is
real hardware with Vendor=13d3 ProdID=3579, manufactured by MediaTek
Inc.

**Step 1.4: Hidden Bug Fix?**
Record: This is not a hidden bug fix. It is a straightforward new device
ID addition to an existing driver. It falls into the "device ID
addition" exception category.

## PHASE 2: DIFF ANALYSIS

**Step 2.1: Inventory**
- Files changed: `drivers/bluetooth/btusb.c` only
- Lines: +3, -1 (net +2 lines)
- Change: Adds one USB_DEVICE entry (13d3/3579) with BTUSB_MEDIATEK |
  BTUSB_WIDEBAND_SPEECH flags, plus a comment "MediaTek MT7902 Bluetooth
  devices"
- Scope: Single-file, single-table, trivially contained

**Step 2.2: Code Flow**
The change adds an entry to the `quirks_table[]` static array. This is a
USB device matching table. When a USB device with VID=0x13d3 PID=0x3579
is plugged in, the btusb driver will now claim it with BTUSB_MEDIATEK
and BTUSB_WIDEBAND_SPEECH flags, causing the MediaTek initialization
path (btmtk) to be used.

**Step 2.3: Bug Mechanism**
Category: Hardware enablement (device ID addition). Without this ID, the
MT7902 Bluetooth hardware is not recognized by the btusb driver, leaving
users without Bluetooth.

**Step 2.4: Fix Quality**
The fix itself is a trivial 2-line device ID table addition, following
the exact pattern of dozens of existing entries. It is obviously correct
in isolation. However, it has a **critical dependency** - see Phase 3.

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: Blame**
Verified: The surrounding code (other 13d3 device IDs like 3578, 3583,
3606) was introduced by various authors from 2021-2024 and is well-
established. The btusb MediaTek infrastructure has been in the tree
since ~2021.

**Step 3.2: Fixes tag**
N/A - no Fixes: tag (expected for device ID additions).

**Step 3.3: File History**
Recent changes to `drivers/bluetooth/btusb.c` include other device ID
additions (e.g., commit 6c0568b7741a3 adding USB ID 7392:e611 for
Edimax). This is a well-trodden path.

**Step 3.4: Author**
Sean Wang is a MediaTek Bluetooth developer and regular contributor. He
has 10+ commits in `drivers/bluetooth/` including MediaTek-specific
fixes and firmware support. The commit was merged by Luiz Augusto von
Dentz, the Bluetooth subsystem maintainer.

**Step 3.5: Dependencies - CRITICAL FINDING**
This commit is patch 3/4 of a series. Patch 2/4 ("Bluetooth: btmtk: add
MT7902 MCU support") adds:
1. `case 0x7902:` to the switch in `btmtk_usb_setup()` (btmtk.c line
   ~1328)
2. `#define FIRMWARE_MT7902` to btmtk.h

**Without patch 2/4, this commit would cause the btusb driver to claim
the device, but `btmtk_usb_setup()` would hit the `default:` case at
line 1369 and return `-ENODEV` with "Unsupported hardware variant
(00007902)"**. The device would be claimed but non-functional.

Verified: grep confirmed `0x7902` is NOT in btmtk.c's switch and
`FIRMWARE_MT7902` is NOT defined in btmtk.h in this tree.

## PHASE 4: MAILING LIST RESEARCH

**Step 4.1: Original Discussion**
Found the original submission at spinics.net (mirror of linux-bluetooth
list). This was submitted as patch 3/4 on 2026-02-19. A reviewer
(Bitterblue Smith) noted a copy-paste error in the commit message body
text ("MT7922" should be "MT7902").

**Step 4.2: Reviewers**
Sent to linux-bluetooth@vger.kernel.org and linux-
mediatek@lists.infradead.org. Merged by the Bluetooth subsystem
maintainer (Luiz Augusto von Dentz).

**Step 4.3: User Reports**
Multiple users confirmed they have MT7902 hardware:
- OnlineLearningTutorials reported PID 13d3/3580 (another MT7902
  variant)
- Two additional USB IDs (13d3/3594, 13d3/3596) were reported
- Bitterblue Smith reported 0e8d/1ede (yet another MT7902 variant)
- Sean Wang acknowledged these and promised to add them in a future
  version

This confirms real user demand for MT7902 support.

**Step 4.4/4.5: Series and Stable Context**
The series is 4 patches: SDIO ID (1/4), MCU support (2/4), USB ID (3/4),
SDIO support (4/4). Patches 1 and 4 are for SDIO and not needed for USB.
Patch 2 is required for this commit.

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1-5.4: Function Analysis**
The change is to a static data table (`quirks_table[]`), not a function.
The table is used by the USB subsystem's device matching mechanism. When
a matching USB device is found, `btusb_probe()` is called, which sets up
the device using MediaTek-specific code paths (via `btmtk_usb_setup()`).

The `btmtk_fw_get_filename()` function at line 112-127 already handles
0x7902 correctly via its `else` branch (generates
"mediatek/BT_RAM_CODE_MT7902_1_X_hdr.bin"). The only missing piece is
the `case 0x7902:` in the switch statement to reach that code path.

## PHASE 6: STABLE TREE ANALYSIS

**Step 6.1: Buggy Code in Stable?**
The btusb driver and MediaTek support infrastructure (BTUSB_MEDIATEK)
exist in this stable tree (7.0). There are already ~70 BTUSB_MEDIATEK
entries. The code to support MT7902 exists in principle (same firmware
loading path as MT7922/MT7925/MT7961), but the specific device ID 0x7902
is not handled in btmtk.c's switch.

**Step 6.2: Backport Complications**
The USB device ID addition itself would apply cleanly. However, it MUST
be accompanied by patch 2/4 (adding `case 0x7902:` to btmtk.c). That
patch is also trivially small (1 line in btmtk.c, 1 line in btmtk.h).

**Step 6.3: Related Fixes in Stable**
No MT7902 support exists in this stable tree.

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1:** Bluetooth subsystem (`drivers/bluetooth/`), Criticality:
IMPORTANT. Bluetooth is used widely on laptops and desktops.

**Step 7.2:** The btusb driver is actively developed with frequent
device ID additions.

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: Affected Users**
Users with MediaTek MT7902 Bluetooth hardware (13d3/3579 variant). The
mailing list confirms multiple people have this hardware.

**Step 8.2: Trigger**
Without this patch: Bluetooth hardware is not recognized at all. No
Bluetooth functionality.

**Step 8.3: Severity**
Without this: complete hardware non-functionality (no Bluetooth). With
this (plus dependency): hardware works. Severity of the absence: HIGH
for affected users.

**Step 8.4: Risk-Benefit**
- BENEFIT: Enables Bluetooth on MT7902 hardware. Users have no
  workaround.
- RISK: Extremely low. Device ID table additions are the safest possible
  changes - they only affect users who have the specific hardware.
  Combined with the dependency, total change is ~4 lines.

## PHASE 9: FINAL SYNTHESIS

**Evidence FOR backporting:**
- Classic device ID addition pattern - explicitly allowed in stable
- Trivially small change (2 lines in btusb.c)
- Real users need this (confirmed on mailing list by multiple people)
- Follows exact pattern of 70+ existing BTUSB_MEDIATEK entries
- Written by MediaTek developer, merged by Bluetooth maintainer
- Zero risk to users without this hardware

**Evidence AGAINST backporting:**
- Requires a companion patch (2/4: btmtk MCU support) to function
- Without that companion, this would make things slightly worse (device
  claimed but non-functional)
- Part of a 4-patch series (though only 2/4 is needed for USB)

**Stable Rules Checklist:**
1. Obviously correct? YES - trivial table entry following established
   pattern
2. Fixes real bug? YES - enables hardware that doesn't work without it
3. Important? YES for affected users - complete Bluetooth failure
4. Small/contained? YES - 2 lines
5. No new features/APIs? Correct - device ID in existing driver
6. Applies to stable? YES, with dependency

**Exception Category:** NEW DEVICE ID to existing driver - explicitly
allowed.

## Verification

- [Phase 1] Parsed tags: Sean Wang (MediaTek dev) authored, Luiz von
  Dentz (BT maintainer) merged
- [Phase 2] Diff: 2 lines added to `quirks_table[]` in btusb.c, adds
  USB_DEVICE(0x13d3, 0x3579)
- [Phase 3] git blame: surrounding entries from 2021-2024, well-
  established table
- [Phase 3] Dependency: grep confirmed 0x7902 NOT in btmtk.c switch,
  FIRMWARE_MT7902 NOT in btmtk.h
- [Phase 3] btmtk_usb_setup default case returns -ENODEV (line
  1369-1372), confirmed by reading code
- [Phase 4] Found original submission at spinics.net/lists/linux-
  bluetooth/msg126673.html
- [Phase 4] Multiple users confirmed MT7902 hardware on mailing list
  (msg126726, msg126732)
- [Phase 4] Sean Wang promised additional MT7902 VID/PIDs (msg126729)
- [Phase 5] btmtk_fw_get_filename() else clause handles 0x7902 correctly
  (line 123-126)
- [Phase 6] BTUSB_MEDIATEK infrastructure confirmed present (70 entries,
  grep verified)
- [Phase 6] MT7902 MCU support NOT present in stable 7.0 tree (grep
  verified)
- [Phase 8] Risk is extremely low - only affects specific hardware,
  follows existing pattern
- DEPENDENCY: Patch 2/4 ("Bluetooth: btmtk: add MT7902 MCU support") is
  REQUIRED for this to function

This is a textbook device ID addition that should be backported to
stable, with the caveat that patch 2/4 from the same series must also be
included. Without that companion patch, the device would be claimed but
fail initialization. The combined change is ~4 lines and extremely low
risk.

**YES**

 drivers/bluetooth/btusb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index d07db8e3a79d5..1acc07d0dc061 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -671,7 +671,9 @@ static const struct usb_device_id quirks_table[] = {
 						     BTUSB_WIDEBAND_SPEECH },
 	{ USB_DEVICE(0x13d3, 0x3606), .driver_info = BTUSB_MEDIATEK |
 						     BTUSB_WIDEBAND_SPEECH },
-
+	/* MediaTek MT7902 Bluetooth devices */
+	{ USB_DEVICE(0x13d3, 0x3579), .driver_info = BTUSB_MEDIATEK |
+						     BTUSB_WIDEBAND_SPEECH },
 	/* MediaTek MT7922 Bluetooth devices */
 	{ USB_DEVICE(0x13d3, 0x3585), .driver_info = BTUSB_MEDIATEK |
 						     BTUSB_WIDEBAND_SPEECH },
-- 
2.53.0


  parent reply	other threads:[~2026-04-20 13:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260420132314.1023554-1-sashal@kernel.org>
2026-04-20 13:16 ` [PATCH AUTOSEL 6.18] Bluetooth: hci_sync: annotate data-races around hdev->req_status Sasha Levin
2026-04-20 13:16 ` Sasha Levin [this message]
2026-04-20 13:17 ` [PATCH AUTOSEL 7.0-6.12] Bluetooth: btusb: MediaTek MT7922: Add VID 0489 & PID e11d Sasha Levin
2026-04-20 13:17 ` [PATCH AUTOSEL 7.0-6.12] Bluetooth: btusb: Add Lite-On 04ca:3807 for MediaTek MT7921 Sasha Levin
2026-04-20 13:18 ` [PATCH AUTOSEL 7.0-6.12] Bluetooth: btmtk: add MT7902 MCU support Sasha Levin
2026-04-20 13:18 ` [PATCH AUTOSEL 7.0-6.1] Bluetooth: btmtk: improve mt79xx firmware setup retry flow Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 7.0-6.12] Bluetooth: btusb: MT7922: Add VID/PID 0489/e174 Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 7.0-5.10] Bluetooth: L2CAP: CoC: Disconnect if received packet size exceeds MPS Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 7.0-5.10] Bluetooth: btbcm: Add entry for BCM4343A2 UART Bluetooth Sasha Levin

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=20260420132314.1023554-23-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=luiz.von.dentz@intel.com \
    --cc=marcel@holtmann.org \
    --cc=patches@lists.linux.dev \
    --cc=sean.wang@mediatek.com \
    --cc=stable@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox