Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_sync: Write the default page timeout to the controller
@ 2026-11-22 15:34 Simon Mikuda
  2026-11-22 17:32 ` bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Mikuda @ 2026-11-22 15:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Simon Mikuda, Marcel Holtmann, Luiz Augusto von Dentz

MGMT Set Default System Configuration takes a page timeout (0x0007),
and Read Default System Configuration reports it back, but nothing
sends it to the controller: HCI_OP_WRITE_PG_TIMEOUT is defined and
never used. BlueZ's PageTimeout in main.conf therefore has no effect,
and the controller pages for its default 5.12 s. A page sent without a
clock offset can need longer than that, so connecting to a device fails
with a page timeout that a longer setting was meant to avoid.

Write the page timeout during BR/EDR init when one is set, as every
reset puts the controller back to its default, and write it at once
when it is set while the controller is up. Zero, its value until it is
set, leaves the controller's default.

Steps to reproduce:
1. Set PageTimeout = 16384 in the [BR] section of BlueZ's main.conf
   and restart bluetoothd.
2. btmon shows no HCI Write Page Timeout, and connecting to a device
   that is out of range still ends with Page Timeout after 5.12 s.

Fixes: 17896406ff35 ("Bluetooth: implement read/set default system parameters mgmt")
Signed-off-by: Simon Mikuda <simon.mikuda@streamunlimited.com>
---
 include/net/bluetooth/hci_sync.h |  1 +
 net/bluetooth/hci_sync.c         | 16 ++++++++++++++++
 net/bluetooth/mgmt_config.c      |  8 ++++++++
 3 files changed, 25 insertions(+)

diff --git a/include/net/bluetooth/hci_sync.h b/include/net/bluetooth/hci_sync.h
index 59cb918d1405..26333d27bd96 100644
--- a/include/net/bluetooth/hci_sync.h
+++ b/include/net/bluetooth/hci_sync.h
@@ -132,6 +132,7 @@ int hci_read_tx_power_sync(struct hci_dev *hdev, __le16 handle, u8 type);
 int hci_write_sc_support_sync(struct hci_dev *hdev, u8 val);
 int hci_read_clock_sync(struct hci_dev *hdev, struct hci_cp_read_clock *cp);
 
+int hci_write_page_timeout_sync(struct hci_dev *hdev);
 int hci_write_fast_connectable_sync(struct hci_dev *hdev, bool enable);
 int hci_update_scan_sync(struct hci_dev *hdev);
 int hci_update_scan(struct hci_dev *hdev);
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 638589f77081..c1e03ce5c1c2 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -3915,6 +3915,20 @@ static int hci_write_auth_enable_sync(struct hci_dev *hdev)
 				     HCI_CMD_TIMEOUT);
 }
 
+int hci_write_page_timeout_sync(struct hci_dev *hdev)
+{
+	__le16 timeout;
+
+	if (!hdev->def_page_timeout || !lmp_bredr_capable(hdev))
+		return 0;
+
+	timeout = cpu_to_le16(hdev->def_page_timeout);
+
+	return __hci_cmd_sync_status(hdev, HCI_OP_WRITE_PG_TIMEOUT,
+				     sizeof(timeout), &timeout,
+				     HCI_CMD_TIMEOUT);
+}
+
 int hci_write_fast_connectable_sync(struct hci_dev *hdev, bool enable)
 {
 	struct hci_cp_write_page_scan_activity cp;
@@ -4522,6 +4536,8 @@ static const struct hci_init_stage hci_init2[] = {
 	HCI_INIT(hci_read_local_ext_features_1_sync),
 	/* HCI_OP_WRITE_AUTH_ENABLE */
 	HCI_INIT(hci_write_auth_enable_sync),
+	/* HCI_OP_WRITE_PG_TIMEOUT */
+	HCI_INIT(hci_write_page_timeout_sync),
 	{}
 };
 
diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c
index 834220072450..1ed6a07abad0 100644
--- a/net/bluetooth/mgmt_config.c
+++ b/net/bluetooth/mgmt_config.c
@@ -135,6 +135,11 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
 	return ret;
 }
 
+static int page_timeout_sync(struct hci_dev *hdev, void *data)
+{
+	return hci_write_page_timeout_sync(hdev);
+}
+
 #define TO_TLV(x)		((struct mgmt_tlv *)(x))
 #define TLV_GET_LE32(tlv)	le32_to_cpu(*((__le32 *)(TO_TLV(tlv)->value)))
 #define TLV_GET_LE16(tlv)	le16_to_cpu(*((__le16 *)(TO_TLV(tlv)->value)))
@@ -268,6 +273,9 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
 			break;
 		case 0x0007:
 			hdev->def_page_timeout = TLV_GET_LE16(buffer);
+			if (test_bit(HCI_UP, &hdev->flags))
+				hci_cmd_sync_queue(hdev, page_timeout_sync,
+						   NULL, NULL);
 			break;
 		case 0x0008:
 			hdev->sniff_min_interval = TLV_GET_LE16(buffer);

base-commit: 4fe38719e6738feaa90486e36b0790dd5d960a96
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: Bluetooth: hci_sync: Write the default page timeout to the controller
  2026-11-22 15:34 [PATCH] Bluetooth: hci_sync: Write the default page timeout to the controller Simon Mikuda
@ 2026-11-22 17:32 ` bluez.test.bot
  0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-11-22 17:32 UTC (permalink / raw)
  To: linux-bluetooth, simon.mikuda

[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]

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/series/1218700/

---Test result---

Test Summary:
CheckPatch                    PASS      1.21 seconds
VerifyFixes                   PASS      0.12 seconds
VerifySignedoff               PASS      0.11 seconds
GitLint                       PASS      0.33 seconds
SubjectPrefix                 PASS      0.11 seconds
BuildKernel                   PASS      30.89 seconds
CheckAllWarning               PASS      35.02 seconds
CheckSparse                   PASS      37.70 seconds
BuildKernel32                 PASS      30.82 seconds
CheckKernelLLVM               PASS      33.34 seconds
TestRunnerSetup               PASS      746.78 seconds
TestRunner_l2cap-tester       PASS      14.95 seconds
TestRunner_iso-tester         PASS      13.34 seconds
TestRunner_bnep-tester        PASS      3.18 seconds
TestRunner_mgmt-tester        PASS      89.30 seconds
TestRunner_rfcomm-tester      PASS      4.50 seconds
TestRunner_sco-tester         PASS      5.58 seconds
TestRunner_ioctl-tester       PASS      4.71 seconds
TestRunner_mesh-tester        PASS      4.54 seconds
TestRunner_smp-tester         PASS      4.37 seconds
TestRunner_userchan-tester    PASS      3.25 seconds
TestRunner_6lowpan-tester     PASS      4.45 seconds
IncrementalBuild              PASS      28.92 seconds



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

---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-22 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 15:34 [PATCH] Bluetooth: hci_sync: Write the default page timeout to the controller Simon Mikuda
2026-11-22 17:32 ` bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox