From: Kyle Pepper <cochcoder@proton.me>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com
Subject: [PATCH v4] Bluetooth: request LE data length for MT7922
Date: Tue, 24 Nov 2026 14:03:39 +0000 [thread overview]
Message-ID: <20261124140325.3092381-1-cochcoder@proton.me> (raw)
In-Reply-To: <20261123233502.222664-1-cochcoder@proton.me>
MT7922 USB firmware can accept maximum LE suggested default data lengths
without negotiating a larger transmit data length on a new connection.
On an ASUS G614PR with USB ID 0489:e0f6 and firmware 20260724143815,
ASHA playback remains choppy until an explicit LE Set Data Length request.
A request on the same Cochlear Nucleus 8 connection raises delivery from
21.5 to 50 audio SDUs/s and reduces peak outstanding packets from 32 to 3.
Set a quirk for MT7922 in USB setup and request the current suggested
defaults after successful remote feature exchange on central-role links.
Require local and remote DLE support and the LE Set Data Length command.
Keep suggested-default initialization and PHY negotiation unchanged.
Do not restrict the workaround to the tested firmware build or OEM USB
ID: the affected firmware range has not been confirmed. Other MediaTek
chips do not enable the quirk. The request also applies to 1M peers that
support DLE, and ordinary link-layer negotiation determines the result.
Hold a connection reference while queued and revalidate its membership,
state, role and capabilities before sending. Release the reference on
completion, cancellation or queue failure. A failed optional request
does not reject connection setup.
OpenCode and Codex assisted with the implementation, review and testing.
Signed-off-by: Kyle Pepper <cochcoder@proton.me>
---
Changes in this revision: disclose AI assistance in the changelog.
No source changes.
Previous version: https://lore.kernel.org/r/20261123233502.222664-1-cochcoder@proton.me/
A firmware fix remains preferable; the affected firmware scope is
unconfirmed. Wider hardware, suspend/resume, other profiles and
native concurrency testing remain open. GCC/Clang W=1 builds and
82 source-extracted sanitizer controls passed on the v2 source.
diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
index 1b3dab0d1..1869815cc 100644
--- a/drivers/bluetooth/btmtk.c
+++ b/drivers/bluetooth/btmtk.c
@@ -1858,6 +1858,10 @@ int btmtk_usb_setup(struct hci_dev *hdev)
btmtk_data->dev_id = dev_id;
+ /* MT7922 needs per-link requests despite suggested defaults. */
+ if (dev_id == 0x7922)
+ hci_set_quirk(hdev, HCI_QUIRK_NEEDS_LE_SET_DATA_LEN);
+
err = btmtk_register_coredump(hdev, btmtk_data->drv_name, fw_version);
if (err < 0)
bt_dev_err(hdev, "Failed to register coredump (%d)", err);
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index efb85c781..85a4931e5 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -348,6 +348,11 @@ enum {
*/
HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE,
+ /* The controller needs an explicit LE Set Data Length request for
+ * each central-role connection despite accepting suggested defaults.
+ */
+ HCI_QUIRK_NEEDS_LE_SET_DATA_LEN,
+
/*
* When this quirk is set, the reserved bits of Primary/Secondary_PHY
* inside the LE Extended Advertising Report events are discarded.
diff --git a/include/net/bluetooth/hci_sync.h b/include/net/bluetooth/hci_sync.h
index 509ec4161..eab827dfa 100644
--- a/include/net/bluetooth/hci_sync.h
+++ b/include/net/bluetooth/hci_sync.h
@@ -195,6 +195,7 @@ int hci_le_read_remote_features(struct hci_conn *conn);
int hci_acl_change_pkt_type(struct hci_conn *conn, u16 pkt_type);
int hci_le_set_phy(struct hci_conn *conn, u8 tx_phys, u8 rx_phys, u16 phy_opts);
+int hci_le_set_data_len(struct hci_conn *conn);
int hci_le_set_cig_params_sync(struct hci_dev *hdev, u8 cig_id);
int hci_le_create_big_sync(struct hci_conn *conn, struct bt_iso_qos_ext *qos,
u8 num_bis);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index b6c7f9a9f..7ef2c4d19 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -7436,6 +7436,14 @@ static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev, void *data,
*/
conn->le_tx_def_phys &= ~HCI_LE_SET_PHY_HDT;
conn->le_rx_def_phys &= ~HCI_LE_SET_PHY_HDT;
+
+ if (hci_test_quirk(hdev, HCI_QUIRK_NEEDS_LE_SET_DATA_LEN) &&
+ conn->role == HCI_ROLE_MASTER &&
+ (hdev->commands[33] & BIT(6)) &&
+ (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) &&
+ (conn->le_features[0] & HCI_LE_DATA_LEN_EXT) &&
+ hdev->le_def_tx_len > 27)
+ hci_le_set_data_len(conn);
}
if (conn->state == BT_CONFIG) {
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 2e88af51b..ac82aa085 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -9286,3 +9286,61 @@ int hci_le_eks_oppt_encrypt(struct hci_conn *conn)
return err;
}
+
+static void le_set_data_len_complete(struct hci_dev *hdev, void *data, int err)
+{
+ struct hci_conn *conn = data;
+
+ bt_dev_dbg(hdev, "err %d", err);
+ if (err && err != -ECANCELED && err != -ENODEV)
+ bt_dev_warn(hdev, "Failed to set LE data length (%d)", err);
+ hci_conn_put(conn);
+}
+
+static int hci_le_set_data_len_sync(struct hci_dev *hdev, void *data)
+{
+ struct hci_conn *conn = data;
+ struct hci_cp_le_set_data_len cp;
+
+ hci_dev_lock(hdev);
+
+ if (!hci_conn_valid(hdev, conn) || conn->type != LE_LINK ||
+ conn->role != HCI_ROLE_MASTER ||
+ (conn->state != BT_CONNECTED && conn->state != BT_CONFIG)) {
+ hci_dev_unlock(hdev);
+ return -ECANCELED;
+ }
+
+ /* Use the current suggested defaults, including later host changes. */
+ if (!hci_test_quirk(hdev, HCI_QUIRK_NEEDS_LE_SET_DATA_LEN) ||
+ !(hdev->commands[33] & BIT(6)) ||
+ !(hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) ||
+ !(conn->le_features[0] & HCI_LE_DATA_LEN_EXT) ||
+ hdev->le_def_tx_len <= 27) {
+ hci_dev_unlock(hdev);
+ return 0;
+ }
+
+ cp.handle = cpu_to_le16(conn->handle);
+ cp.tx_len = cpu_to_le16(hdev->le_def_tx_len);
+ cp.tx_time = cpu_to_le16(hdev->le_def_tx_time);
+
+ hci_dev_unlock(hdev);
+
+ return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_DATA_LEN,
+ sizeof(cp), &cp, HCI_CMD_TIMEOUT);
+}
+
+int hci_le_set_data_len(struct hci_conn *conn)
+{
+ struct hci_dev *hdev = conn->hdev;
+ int err;
+
+ err = hci_cmd_sync_queue_once(hdev, hci_le_set_data_len_sync,
+ hci_conn_get(conn),
+ le_set_data_len_complete);
+ if (err)
+ hci_conn_put(conn);
+
+ return (err == -EEXIST) ? 0 : err;
+}
base-commit: ffb95458a0f70dcab620eee0ecf5ef7750971b2f
prev parent reply other threads:[~2026-11-24 14:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 23:35 [PATCH v3] Bluetooth: request LE data length for MT7922 Kyle Pepper
2026-11-24 7:10 ` [v3] " bluez.test.bot
2026-11-24 14:03 ` Kyle Pepper [this message]
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=20261124140325.3092381-1-cochcoder@proton.me \
--to=cochcoder@proton.me \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox