All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_core: Fix inquiry cache timestamps on 64-bit systems
@ 2026-09-22  2:01 Linmao Li
  2026-09-22  2:31 ` bluez.test.bot
  2026-09-22 15:00 ` [PATCH] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Linmao Li @ 2026-09-22  2:01 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, luiz.dentz, linux-kernel, stable, Linmao Li

On 64-bit systems, outgoing BR/EDR connections always fall back to page
scan repetition mode R2 with no clock offset once the system has been
up for more than five minutes, even when inquiry found the peer only
seconds earlier. This lengthens paging and can increase the risk of a
Page Timeout.

The inquiry cache stores jiffies in __u32 timestamps, but its age
helpers subtract them from unsigned long jiffies. INITIAL_JIFFIES casts
-300 * HZ through unsigned int, so jiffies crosses 2^32 five minutes
after boot on 64-bit systems. Assigning it to __u32 then drops the upper
32 bits. In one trace, a 7.6-second-old entry (HZ=1000) was reported as
2^32 + 7620 ticks old and rejected by hci_acl_create_conn_sync().
hci_inquiry() is affected by the same truncation when checking the whole
cache. 32-bit systems are unaffected because unsigned long is 32 bits
wide there.

Use unsigned long for both timestamps so they have the same width as
jiffies on 32-bit and 64-bit systems, and update the debugfs format
specifier accordingly.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
---
 include/net/bluetooth/hci_core.h | 4 ++--
 net/bluetooth/hci_debugfs.c      | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index b26004a05368..788d6600f500 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -63,7 +63,7 @@ struct inquiry_entry {
 		NAME_PENDING,
 		NAME_KNOWN,
 	} name_state;
-	__u32			timestamp;
+	unsigned long		timestamp;
 	struct inquiry_data	data;
 };
 
@@ -79,7 +79,7 @@ struct discovery_state {
 	struct list_head	all;	/* All devices found during inquiry */
 	struct list_head	unknown;	/* Name state not known */
 	struct list_head	resolve;	/* Name needs to be resolved */
-	__u32			timestamp;
+	unsigned long		timestamp;
 	bdaddr_t		last_adv_addr;
 	u8			last_adv_addr_type;
 	s8			last_adv_rssi;
diff --git a/net/bluetooth/hci_debugfs.c b/net/bluetooth/hci_debugfs.c
index aadffaaff20e..2559fb6324d6 100644
--- a/net/bluetooth/hci_debugfs.c
+++ b/net/bluetooth/hci_debugfs.c
@@ -364,7 +364,7 @@ static int inquiry_cache_show(struct seq_file *f, void *p)
 
 	list_for_each_entry(e, &cache->all, all) {
 		struct inquiry_data *data = &e->data;
-		seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
+		seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %lu\n",
 			   &data->bdaddr,
 			   data->pscan_rep_mode, data->pscan_period_mode,
 			   data->pscan_mode, data->dev_class[2],
-- 
2.25.1


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

* RE: Bluetooth: hci_core: Fix inquiry cache timestamps on 64-bit systems
  2026-09-22  2:01 [PATCH] Bluetooth: hci_core: Fix inquiry cache timestamps on 64-bit systems Linmao Li
@ 2026-09-22  2:31 ` bluez.test.bot
  2026-09-22 15:00 ` [PATCH] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-09-22  2:31 UTC (permalink / raw)
  To: linux-bluetooth, lilinmao

[-- Attachment #1: Type: text/plain, Size: 1958 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/1170901/

---Test result---

Test Summary:
CheckPatch                    PASS      0.61 seconds
VerifyFixes                   PASS      0.09 seconds
VerifySignedoff               PASS      0.16 seconds
GitLint                       PASS      0.26 seconds
SubjectPrefix                 PASS      0.92 seconds
BuildKernel                   PASS      18.39 seconds
CheckAllWarning               PASS      23.54 seconds
CheckSparse                   PASS      26.65 seconds
BuildKernel32                 PASS      22.17 seconds
CheckKernelLLVM               PASS      21.37 seconds
TestRunnerSetup               PASS      477.87 seconds
TestRunner_l2cap-tester       PASS      17.38 seconds
TestRunner_iso-tester         PASS      24.92 seconds
TestRunner_bnep-tester        PASS      3.23 seconds
TestRunner_mgmt-tester        PASS      53.59 seconds
TestRunner_rfcomm-tester      PASS      3.92 seconds
TestRunner_sco-tester         PASS      6.86 seconds
TestRunner_ioctl-tester       PASS      4.01 seconds
TestRunner_mesh-tester        FAIL      6.66 seconds
TestRunner_smp-tester         PASS      3.88 seconds
TestRunner_userchan-tester    PASS      3.04 seconds
TestRunner_6lowpan-tester     PASS      3.94 seconds
IncrementalBuild              PASS      18.33 seconds

Details
##############################
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.758 seconds
Mesh - Send cancel - 2                               Timed out    1.999 seconds


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

---
Regards,
Linux Bluetooth


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

* Re: [PATCH] Bluetooth: hci_core: Fix inquiry cache timestamps on 64-bit systems
  2026-09-22  2:01 [PATCH] Bluetooth: hci_core: Fix inquiry cache timestamps on 64-bit systems Linmao Li
  2026-09-22  2:31 ` bluez.test.bot
@ 2026-09-22 15:00 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2026-09-22 15:00 UTC (permalink / raw)
  To: Linmao Li; +Cc: linux-bluetooth, marcel, luiz.dentz, linux-kernel, stable

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 22 Sep 2026 10:01:41 +0800 you wrote:
> On 64-bit systems, outgoing BR/EDR connections always fall back to page
> scan repetition mode R2 with no clock offset once the system has been
> up for more than five minutes, even when inquiry found the peer only
> seconds earlier. This lengthens paging and can increase the risk of a
> Page Timeout.
> 
> The inquiry cache stores jiffies in __u32 timestamps, but its age
> helpers subtract them from unsigned long jiffies. INITIAL_JIFFIES casts
> -300 * HZ through unsigned int, so jiffies crosses 2^32 five minutes
> after boot on 64-bit systems. Assigning it to __u32 then drops the upper
> 32 bits. In one trace, a 7.6-second-old entry (HZ=1000) was reported as
> 2^32 + 7620 ticks old and rejected by hci_acl_create_conn_sync().
> hci_inquiry() is affected by the same truncation when checking the whole
> cache. 32-bit systems are unaffected because unsigned long is 32 bits
> wide there.
> 
> [...]

Here is the summary with links:
  - Bluetooth: hci_core: Fix inquiry cache timestamps on 64-bit systems
    https://git.kernel.org/bluetooth/bluetooth-next/c/ea983244b99a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-09-22 15:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-22  2:01 [PATCH] Bluetooth: hci_core: Fix inquiry cache timestamps on 64-bit systems Linmao Li
2026-09-22  2:31 ` bluez.test.bot
2026-09-22 15:00 ` [PATCH] " patchwork-bot+bluetooth

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.