From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.228.134 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796058577; b=tsu7THxHtiRab5BMWu22q5LbZhSY6EhRnwaQweoq0DKMYDuH0Nuw7oqINE3v9a/OmvxH WcGfeBEST+uraarvn666yHd5tiYSG+alyhwbB0SkgmZ/JSQiz2L3gwJhqgiHNze1KP1Ga kHKogqvqqBh46vf09QFhKNgK6jrw3x4UJVoh3UAJDSpEBZLT1tjhUAjzEXDYTNVzQpBAW lNR4JhYJ0tOGhiqCkUAIUYYYWwVx9riOV+VBcwaxxUOP6fwXx+vGpqZ8O245ZsL0Cq1bS MQyoAMKGwcWQeP2fovMTHyZOPc/Wx2kKEn9tGiMfJ5/O+HRfPaVErh7OqyiuKRR7Rag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796058577; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:Date:Subject:To: Content-Type:Message-ID; bh=yYAsL8oajdKllTq4kgkRzMm7BMqQOwLhLWwCqeK/5hs=; b=ostXRoJ8Uall/NB0+YUS0DMJjS0Av1fFn0BJT3CLH3REvbIvIx3Aodyth+OpFMSefhwe +aJftyrJQBJJ3CLT/XC6uXjgBoaE4ky6fxNKdriVFnoYiNoy2pqtgUJoV1IHi9E9YRTNR MBukK6f5/mNC5Q2Bt4NGMYwnytskjPWIBcyI1SDw4a48kgiAwfbR8CULbOtAvO6qIqJua QBodpYL8rfpBvdBNhB+tyDtRh758tZPXdmVW7xgDCRwCnRBXYIT+BTcZJ4Yl6zPt0SzED ErV2Jlf85ZOQ3/9Z1VAS64PECF00aDelzbijt5E179iL4bDD0ZPLsmroADvARXGsXkQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=m8RHlWQT; arc=none smtp.remote-ip=74.125.228.134 Received: from mail-ej2-f6.google.com (mail-ej2-f6.google.com [74.125.228.134]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 648D9606A329 for ; Mon, 30 Nov 2026 17:09:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 648D9606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=m8RHlWQT Received: by mail-ej2-f6.google.com with SMTP id a640c23a62f3a-c410cdcab7dso305483166b.0 for ; Mon, 30 Nov 2026 09:09:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796058576; x=1796663376; darn=vger.kernel.org; h=message-id:content-type:to:subject:date:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=yYAsL8oajdKllTq4kgkRzMm7BMqQOwLhLWwCqeK/5hs=; b=m8RHlWQTktv5NipSlTI6nO5cn8xcX1RuzppWTgJihuLFmrtU0wBg5byxzpujVf1jvP P0+FUSc8+0+1SwC47v2MdIy0VUJ2Du9PEvdX5l9exo/KuUqL3xxcPh1N8oo3mHmL9XGC m/q3eV27ZDOf43y4Zomg9138lrZ0PqX++VIdCMcZRF8+lzjhM8HigFe+dQYRauvAnZbY YUmnA2Y+6cpaZzKo/tSnraealwjrdCOXgvsToTgIZm0JsM9+BLlvXTt7j4QKm6sH/SRt gMXwJJWnLfvaja/F05icaOG468J3+4QONdjN9IhKflqZGjBsp9pV7ly7hB2eKHnfx95K YgVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796058576; x=1796663376; h=message-id:content-type:to:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yYAsL8oajdKllTq4kgkRzMm7BMqQOwLhLWwCqeK/5hs=; b=tQzV/V4WG90obmbJ0H+reatQ1iBNkn1dhavA441DwB5nOk8QPa6v7DyS8kZJKu2t9x 0ezpBO/ABahLG9/i7yA6vcFXEWzHzcWJJ0SPkgSaBI5duJ5F6F3rdJVX82PtehLkZw0G uj+haFmmY/erUfgoWpRkGm2iqZqkjFl9KUdtugSsKdHMDTt+vqQ0DJ74wl5O/LUWQgO1 icZcwBC/ibEfswBnK3XHvOXlPR39iXR8YXFkmJh8mKugejkiZp9RwgtPoMCBMEOjGSQH op6me5PX5+noRH7vBhDKpiUvMBvWZ0bHmbKv8zIl0sX67A7Zd7NJOpVJV5WiEKwvXVBW ZN9g== X-Gm-Message-State: APuU4Z9L2h53B1rV46tsvNvSu/k4nhyacZCcy89TlBAcpRl3qc2z9Btc R6QwvqS1G5eYPLPYDloJHTgM88b+R3B/ImxeVd8I45TBv3FBoPEacRcC718dqC5teei10A== X-Gm-Gg: AZFdTZf8OuZOQ8dRiimXGqcFXYwo5j2IJZI4LG60PZ5F8a79loHO45ory1CCyyYsqS0 wHEAKRyeZKLcuNQVuulLIw0zuH/+82JTgIQJL14IAdU/5Es/0SOwior9k0jOay5srNt+IwRpzcU ewVn7Rj8C5Cyo64cXIA0bnZKOobwcaMIUxbQl2YuyRJ274/3lwtg19muftOV3Hr5cWchGOJ75zR KYP3zmagNBZkjuGfaRGV/Sdhe3WqYoTo29CCCnWfWTgdXzLBSb6nKTXp2v5JRXW9fDWUKXBom52 KOYzjnaFkciIPtcw+G83It8EOCv4G0c9nBEVIWLMxMmJPsECQwzH4eQB1cYWcKZd7ul40m6L/TF wKLKjdr5I3iek+BsPkPUh6LSE72kG2N91MnUisa9FEzBHiVTXtdqg+Ykz6tu71UtH3SQLX0wXYU 8G+1s7cHL3egPhOmCEMnekN9Vj/43DAuslghEo/NJWrBWSo5+iVRwl0+d8EucKrZc+o00d6bKCl OFvZ56NhYZqA1NyB+YOBPdxP520R1b0FR1kGNgwrTe7WhGXlw5cSn1cBs3b0ohJ4PzPCph9VX/Q Sp7gM/9YyH57KIs+TTxZgU3m/qBwyxKw2d4WPS32cuDmyAaRxsiVN9mWk8evqkNbNtQ= X-Received: by 2002:a17:906:9d04:b0:c44:9a32:b27 with SMTP id a640c23a62f3a-c513a846655mr2098759666b.25.1796058575566; Mon, 30 Nov 2026 09:09:35 -0800 (PST) Received: from [127.0.1.1] (31-207-25-210.static.ef-service.nl. [31.207.25.210]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513afc679bsm1183858866b.63.2026.11.30.09.09.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 09:09:35 -0800 (PST) From: Andrea Daoud Date: Mon, 30 Nov 2026 18:09:35 +0100 Subject: [PATCH BlueZ] adapter: Load defaults before probing drivers To: linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Message-ID: <179605857505.1239633.6683321244449767140@gmail.com> X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list With AutoEnable=true, the first automatic power-on can ignore the PageScanInterval set in main.conf. The controller starts listening for BR/EDR connections at its previous interval. The configured interval takes effect only on the next power-on. The reason is that the policy driver's probe can queue Set Powered before adapter registration queues Set Default System Configuration. Linux therefore programs the controller before it receives the configured interval. Queue the defaults before probing adapter drivers so the first automatic power-on uses the configured parameters. --- Explanations: During adapter registration, load_drivers() probes the policy plugin. With AutoEnable enabled and the adapter off, policy_adapter_probe() calls btd_adapter_restore_powered(), which queues Set Powered (0x0005). Registration then calls load_defaults(), which queues Set Default System Configuration (0x004c). At power-on, Linux programs the controller with the page scan values currently stored in hci_dev. The later Set Default System Configuration command updates hci_dev, so the controller picks up the new values only on the next power-on. To reproduce this issue, use a BR/EDR adapter that supports interlaced page scan. Leave fast connectable mode disabled so Linux uses the configured page scan type and interval. Set the following in /etc/bluetooth/main.conf: [Policy] AutoEnable=true [BR] PageScanType=1 PageScanInterval=1024 PageScanWindow=36 Boot with the adapter present. Before toggling adapter power, read the kernel defaults and the two controller registers: bluetoothctl mgmt.read-sysconfig bluetoothctl mgmt.hci-cmd 0x0c1b 0 2 bluetoothctl mgmt.hci-cmd 0x0c46 0 2 The management types 0x0000, 0x0001 and 0x0002 are page scan type, interval and window. The HCI commands are Read Page Scan Activity and Read Page Scan Type. Interval and window use 0.625 ms units. ## Hardware results Tested on an Intel AX200 using the existing Linux BR/EDR page-scan implementation. Interval Window Type BlueZ 5.87, first power-on 1280 ms 11.25 ms standard BlueZ 5.87, after manual off/on 640 ms 22.5 ms interlaced BlueZ 5.87 + patch, first power-on 640 ms 22.5 ms interlaced On both boots, the kernel reported the configured values. On the first power-on, the controller's activity/type replies changed from "00 00 08 12 00" / "00 00" to "00 00 04 24 00" / "00 01" with the patch. src/adapter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapter.c b/src/adapter.c index 112312651..1ec1c7039 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -10011,10 +10011,10 @@ load: load_config(adapter); fix_storage(adapter); + load_defaults(adapter); load_drivers(adapter); btd_profile_foreach(probe_profile, adapter); clear_blocked(adapter); - load_defaults(adapter); load_devices(adapter); /* restore Service Changed CCC value for bonded devices */