* [PATCH BlueZ] adapter: Don't power on while blocked by rfkill
@ 2026-10-24 10:32 Tobias Wilken
2026-10-24 14:23 ` [BlueZ] " bluez.test.bot
2026-10-26 21:40 ` [PATCH BlueZ] " patchwork-bot+bluetooth
0 siblings, 2 replies; 3+ messages in thread
From: Tobias Wilken @ 2026-10-24 10:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Tobias Wilken
btd_adapter_new() reads the rfkill state and sets PowerState to
off-blocked when the adapter is blocked. With AutoEnable, the default
since commit 180cf09933b2 ("policy: Change AutoEnable default to
true"), the policy plugin then calls btd_adapter_restore_powered(),
which sends Set Powered anyway. It can only fail, so every start with
Bluetooth turned off logs an error:
bluetoothd[1212]: Failed to set mode: Failed (0x03)
or, with a kernel that reports the rfkill block:
bluetoothd[1212]: Failed to set mode: Blocked through rfkill (0x12)
Don't send Set Powered from btd_adapter_restore_powered() while rfkill
reports the adapter blocked. The rfkill unblock event calls it again,
and that powers the adapter on as before. If the rfkill state can't be
read, keep the current behaviour. Setting the Powered property over
D-Bus still sends the command and reports the error.
Assisted-by: Claude:claude-opus-5-5
---
Notes:
Tested with bluetoothd built from master on Debian's 7.2.9 kernel,
Bluetooth soft-blocked, AutoEnable at its default:
- without this patch: "Failed to set mode: Failed (0x03)" at start
- with it: no error, PowerState off-blocked
- bluetoothctl power on while blocked: still fails as before
- rfkill unblock: adapter powers on by itself, PowerState on
- block again: off-blocked
make check passes.
src/adapter.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index d3aa03f..1561ea3 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -8260,14 +8260,23 @@ int btd_cancel_authorization(guint id)
int btd_adapter_restore_powered(struct btd_adapter *adapter)
{
bool powered;
+ int blocked;
powered = btd_adapter_get_powered(adapter);
- if (adapter->power_state == ADAPTER_POWER_STATE_OFF_BLOCKED &&
- rfkill_get_blocked(adapter->dev_id) == 0) {
- adapter_set_power_state(adapter,
- powered ?
- ADAPTER_POWER_STATE_ON :
- ADAPTER_POWER_STATE_OFF);
+ if (adapter->power_state == ADAPTER_POWER_STATE_OFF_BLOCKED) {
+ blocked = rfkill_get_blocked(adapter->dev_id);
+
+ /* Powering on can't succeed while blocked, the rfkill
+ * unblock event calls this function again.
+ */
+ if (blocked > 0)
+ return 0;
+
+ if (blocked == 0)
+ adapter_set_power_state(adapter,
+ powered ?
+ ADAPTER_POWER_STATE_ON :
+ ADAPTER_POWER_STATE_OFF);
}
if (powered)
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [BlueZ] adapter: Don't power on while blocked by rfkill
2026-10-24 10:32 [PATCH BlueZ] adapter: Don't power on while blocked by rfkill Tobias Wilken
@ 2026-10-24 14:23 ` bluez.test.bot
2026-10-26 21:40 ` [PATCH BlueZ] " patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-10-24 14:23 UTC (permalink / raw)
To: linux-bluetooth, tooangel
[-- Attachment #1: Type: text/plain, Size: 858 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/1192615/
---Test result---
Test Summary:
CheckPatch PASS 8.11 seconds
GitLint PASS 1.24 seconds
BuildEll PASS 19.48 seconds
BluezMake PASS 297.29 seconds
CheckSmatch PASS 291.11 seconds
bluezmakeextell PASS 93.31 seconds
TestFunctional PASS 1103.66 seconds
IncrementalBuild PASS 303.28 seconds
ScanBuild PASS 1119.50 seconds
https://github.com/bluez/bluez/pull/2707
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH BlueZ] adapter: Don't power on while blocked by rfkill
2026-10-24 10:32 [PATCH BlueZ] adapter: Don't power on while blocked by rfkill Tobias Wilken
2026-10-24 14:23 ` [BlueZ] " bluez.test.bot
@ 2026-10-26 21:40 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2026-10-26 21:40 UTC (permalink / raw)
To: Tobias Wilken; +Cc: linux-bluetooth
Hello:
This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Sat, 24 Oct 2026 12:32:55 +0200 you wrote:
> btd_adapter_new() reads the rfkill state and sets PowerState to
> off-blocked when the adapter is blocked. With AutoEnable, the default
> since commit 180cf09933b2 ("policy: Change AutoEnable default to
> true"), the policy plugin then calls btd_adapter_restore_powered(),
> which sends Set Powered anyway. It can only fail, so every start with
> Bluetooth turned off logs an error:
>
> [...]
Here is the summary with links:
- [BlueZ] adapter: Don't power on while blocked by rfkill
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=aa3d6c761cb1
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-10-26 21:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-24 10:32 [PATCH BlueZ] adapter: Don't power on while blocked by rfkill Tobias Wilken
2026-10-24 14:23 ` [BlueZ] " bluez.test.bot
2026-10-26 21:40 ` [PATCH BlueZ] " patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox