Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1789980rdb; Mon, 8 Jan 2024 10:13:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHfNCW4qQvqwjDtSfyiFZlcpLQsx6MmUDEvnVEiRoNU7eOAY2wjUQdd7QW0/4zWHM/4LWf X-Received: by 2002:a05:6102:418f:b0:467:ae95:4e33 with SMTP id cd15-20020a056102418f00b00467ae954e33mr2019318vsb.48.1704737588602; Mon, 08 Jan 2024 10:13:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704737588; cv=none; d=google.com; s=arc-20160816; b=uOCVyq/TZwBUiZjVJZZt8Gu/GsQn6n8k0C5LUQIgK865MyfypIr9550/l65AD1SDqP 0YswWOZgWzak0HP8izATQs+h9j81UGX7QACwAP2W0J89mbwmAjUmNQ/HyjvjKkWFgtBA E6ybkr2AvUrf+ahNS436GAUvhYrjy/vOG0pc1XT3mqpPDmapASrK3H0FNniWOvd9tyft tWIt/CPHoeJoF5TNno5ZfCiKSkVHQpcDixc04yVWveqge/uPCAPIKXq7Ye3/Pqle0LD+ 6rhh45xokJbbu2wpEwFr6BUkQV3i039Urw8ulg1bxAb+8AU9/nUy6ozpYhMzrRi2KwY2 Ptqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=m3UVrTC07ELqxg07etwEf6qXVGPgDZ/12FKTrGxeD48=; fh=o7w5gnejhTGEEaAZoR/koFXUiqIQPI66DkN9mYlfUF0=; b=usUvWeDjq6ohKbNnKwaazjSKee7hkLlxLjrCRucZYQ77D7YZlmHZlcjV4oZgQ/lS03 x4zofJM60PY30n8KeWo5hS5v0g0oM7VkHjToHjyiHrct6pdDdksbh9WeIJwc6hZo1W+j ZGlxG5gl8XA5dt32YegzFLFgl/tCZDy2hipAGfvBTivXLPD3stKPJEr3jmmYddCKvhS0 zELnSIozrHdXNRvr37r2kWRqAxQBxJvXjucgYugexFgPkRVb4+YNPurxjFAWGCwl/OoG GE8gTaPcLa+iSoT8IyWh8VN/+6I/WwCgV2rAh2YBvtFRGkoPKdnNBC3tvYi9xmv9gCpE lusQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=iqa5JyBj; spf=pass (google.com: domain of linux-bluetooth+bounces-956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-956-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y10-20020a05610207ca00b0046703e0c8f4si106535vsg.488.2024.01.08.10.13.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 10:13:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=iqa5JyBj; spf=pass (google.com: domain of linux-bluetooth+bounces-956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-956-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 57ED21C20894 for ; Mon, 8 Jan 2024 18:13:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DE5B55E77; Mon, 8 Jan 2024 18:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iqa5JyBj" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6958555E5A; Mon, 8 Jan 2024 18:05:16 +0000 (UTC) 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 Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2cd0f4f306fso24236581fa.0; Mon, 08 Jan 2024 10:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704737114; x=1705341914; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=m3UVrTC07ELqxg07etwEf6qXVGPgDZ/12FKTrGxeD48=; b=iqa5JyBj/NyspgcXT0prOt6utH2AET+vn/GX9dWhQbQlZ49J5Nzb8pjLGsCjW0flo/ 2VlGiLqiLUuqDU8KoyrXFKWpmzifK1vijJB/DTlhyctwWpMe+VrkO4Yp6MQsmOy59s+h o2TeI7xNSvSDSOPzk6F6pu3sCe2TxYi/P0xoHqk05x/Ci27iF8LVu8kaBP8z2Y1OhZnF 56YD0NkRBm02Rs5oGvFq8jxi+6ctU/FB2iCGKtubCcx6IujxHj2V1RLk4W6BQSX1H5+p V7cMG1Li7KvdmtXqrDL44OBJDmuuR9xAf62vgmidYJWEmdy4R7V0VtZHDMcBdg6dRTPt MjlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704737114; x=1705341914; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m3UVrTC07ELqxg07etwEf6qXVGPgDZ/12FKTrGxeD48=; b=IOaTt3vLPIX//reiFZSzAjiR9Md/zzEuPwmeAehDw61vX3g/r6gBjAsWmxTSF6DeTD xogqvDYto+CHSLj+yror4vddRJ9oP48VuEgtm6OgLIBTA3mkEQuyXihL2004Qhm3CJ7r 2KbVSweq0/w68Ze2NoeCMzsLkFy4YX5eg0lbdvigRnX4Yl8uudAmrWquPmE7ZA2pFgV6 rGkscY6wjsA2XAlJl99tqumP2jz3qppyFV+aSk84XfLgB1NUuSpw8YB7eAI7aPif6awn Z0V+1FTj23fSIyJ4+ofiRxWFz8Ih92RnJseQRRUAVu6zsxk8jVKPRhMkHQXlAfmmXJFY AQTQ== X-Gm-Message-State: AOJu0YynxOUkauT3V4Z5gihy0wHotc1AyptmeZyrl0R7i2TZwIDcxv7L yEfGJ+omENYLKaRwck5q1qirMh9yOZ8ajbpek60= X-Received: by 2002:a2e:b7d5:0:b0:2cc:e68b:ee5e with SMTP id p21-20020a2eb7d5000000b002cce68bee5emr1708726ljo.1.1704737114025; Mon, 08 Jan 2024 10:05:14 -0800 (PST) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240107180252.73436-1-verdre@v0yd.nl> In-Reply-To: <20240107180252.73436-1-verdre@v0yd.nl> From: Luiz Augusto von Dentz Date: Mon, 8 Jan 2024 13:05:01 -0500 Message-ID: Subject: Re: [PATCH v3 0/4] Disconnect devices before rfkilling adapter To: =?UTF-8?Q?Jonas_Dre=C3=9Fler?= Cc: Marcel Holtmann , Johan Hedberg , asahi@lists.linux.dev, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Jonas, On Sun, Jan 7, 2024 at 1:03=E2=80=AFPM Jonas Dre=C3=9Fler = wrote: > > Apparently the firmware is supposed to power off the bluetooth card > properly, including disconnecting devices, when we use rfkill to block > bluetooth. This doesn't work on a lot of laptops though, leading to weird > issues after turning off bluetooth, like the connection timing out on the > peripherals which were connected, and bluetooth not connecting properly > when the adapter is turned on again after rfkilling. > > This series uses the rfkill hook in the bluetooth subsystem > to execute a few more shutdown commands and make sure that all > devices get disconnected before we close the HCI connection to the adapte= r. > > --- > > v1: https://lore.kernel.org/linux-bluetooth/20240102133311.6712-1-verdre@= v0yd.nl/ > v2: https://lore.kernel.org/linux-bluetooth/20240102181946.57288-1-verdre= @v0yd.nl/ > v3: > - Update commit message titles to reflect what's actually happening > (disconnecting devices, not sending a power-off command). > - Doing the shutdown sequence synchronously instead of async now. > - Move HCI_RFKILLED flag back again to be set before shutdown. > - Added a "fallback" hci_dev_do_close() to the error path because > hci_set_powered_sync() might bail-out early on error. > > Jonas Dre=C3=9Fler (4): > Bluetooth: Remove HCI_POWER_OFF_TIMEOUT > Bluetooth: mgmt: Remove leftover queuing of power_off work > Bluetooth: Add new state HCI_POWERING_DOWN > Bluetooth: Disconnect connected devices before rfkilling adapter > > include/net/bluetooth/hci.h | 2 +- > net/bluetooth/hci_core.c | 35 +++++++++++++++++++++++++++++++++-- > net/bluetooth/hci_sync.c | 16 +++++++++++----- > net/bluetooth/mgmt.c | 30 ++++++++++++++---------------- > 4 files changed, 59 insertions(+), 24 deletions(-) > > -- > 2.43.0 I will probably be applying this sortly, but let's try to add tests to mgmt-tester just to make sure we don't introduce regressions later, btw it seems there are a few suspend test that do connect, for example: Suspend - Success 5 (Pairing - Legacy) - waiting 1 seconds random: crng init done New connection with handle 0x002a Test condition complete, 1 left Suspend - Success 5 (Pairing - Legacy) - waiting done Set the system into Suspend via force_suspend New Controller Suspend event received Test condition complete, 0 left --=20 Luiz Augusto von Dentz