From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380193; b=avMS0fR0nMxGSUT4AoGHM/7bq8oGRvbahnGHUgmcYR+tELomDN7/S4w+fHS8UJG0yvuT UCheRH4OcgAq5r7p7LZN72aQcwc7SDKDJxbwxP/fJGFLUfX+gJWMMmMnmNAzWnB1zoKZP 3Hm8+vRhHc3HBYV77NquATITmGylIz6lsGextdPYAFzNZ/Et7kvCc1p/k6yW4SxD5fYgX 8ksI43pP+Fol339mzm06XKqHTDmLL3kGHeVlYHCnsa18VW7c80g4rFSQEj1XTxo8SkwXM o6YFVnqu/bA9RCrByIuqZ7ioOdBfAnEXf6jxAvcWOGkLukUrKKKSgcD9SK/pY4oJdLw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380193; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=2UeEc/3FFYCSDWSmUF62X4EO+wR0VYI3Ijg83okp0t0=; b=3BkE21ZoHC8cFNid7d2o6BcMbIpHR/mSJX7xUXQwLdbGt3IH0sIqvG7sAjEOHxT0Y2gX LZuhLG3gh+2YcNXlE4MqAD72zsmJN4rJ4MvqqUP9m554+Qt1aKdz/bsCHVFgPq+FhKzLW R5ABOVo0OYqdmcD6inwGtgOV7XAYdrbRi4RUARhrDIkOtrpHkLFLT4ep+HHFjBHTMrVe1 BXOpC0puZWiCghI5Wg63JhazWnmlQrwNjbjPA9HSqeKhZ9eLXqeRlzPKP1U+8QK2R87Z8 nlYgzmWUvNlFeA6JKZrBFNqENStGvC1IQd31lXow+ZtHtTPoXD0LhrY7KgfDgzuQV+g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=x2q5w8+U; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CB80606A330; Fri, 4 Dec 2026 10:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=x2q5w8+U Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDBB01F00933; Fri, 4 Dec 2026 10:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380193; bh=2UeEc/3FFYCSDWSmUF62X4EO+wR0VYI3Ijg83okp0t0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=x2q5w8+UmxuXt9daaWDm+G+NYEr4h3WO3YIPuibXUyHG38t+rDBC2TWD4lmfhnbfT UHwi6jPV8XnBCWIKunfu8JRLTz8s04az7I2GPoU/Qv4ZhmNGguDz2fSpAWVXUY/GJb APJtXdMXAuvwjiSTinEFDASLiO/m8io6fhrKYTmw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thomas de Gruijter , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 7.3 166/742] Bluetooth: MSFT: Only enable the advertisement filter with monitors Date: Fri, 4 Dec 2026 19:00:30 +0900 Message-ID: <20261204100639.514861439@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas de Gruijter [ Upstream commit 4a8f9b7fb4f503f48e2ccfc67caa8b07d303f8a8 ] msft_do_open() unconditionally enables the MSFT LE advertisement filter on every power on, whether or not any advertisement monitor is registered. On MediaTek MT7922 (USB 0e8d:0616, firmware build 20260724) the controller then drops every LE advertisement: LE Set Extended Scan Enable succeeds, but no LE Extended Advertising Report is ever delivered, so LE discovery and passive scanning find nothing. BR/EDR inquiry is not affected. Sending LE Set Advertisement Filter Enable with Enable set to 0x00 restores reporting immediately. The Microsoft HCI extension specification defines the filter as disabled by default and does not specify what a controller reports while the filter is enabled without any monitor condition. Only enable the filter while at least one monitor is offloaded to the controller, and update it after a monitor is added or removed and after the monitors are re-registered on power on and resume. Like the monitors, the filter state does not survive a power off, so reset the tracked state in msft_do_close() instead of sending a redundant disable on power on. A command is only sent when the wanted state differs from msft->filter_enabled, so this depends on the previous patch keeping that state accurate when the controller reports the filter as already being in the requested state. Fixes: 394566bf1e37 ("Bluetooth: advmon offload MSFT handle filter enablement") Signed-off-by: Thomas de Gruijter Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/msft.c | 46 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c index f372df9a98311..db7b40ab5fc16 100644 --- a/net/bluetooth/msft.c +++ b/net/bluetooth/msft.c @@ -468,6 +468,30 @@ static int msft_remove_monitor_sync(struct hci_dev *hdev, return err; } +/* Keep the advertisement filter enabled only while at least one monitor is + * offloaded to the controller. With the filter enabled and no monitors, some + * controllers (e.g. MediaTek MT7922) drop every advertisement, which breaks + * LE discovery and passive scanning entirely. + * + * This function requires the caller holds hci_req_sync_lock + */ +static void msft_update_filter_enable(struct hci_dev *hdev) +{ + struct msft_data *msft = hdev->msft_data; + bool enable, update; + + if (!msft) + return; + + hci_dev_lock(hdev); + enable = !list_empty(&msft->handle_map); + update = enable != msft->filter_enabled; + hci_dev_unlock(hdev); + + if (update) + msft_set_filter_enable(hdev, enable); +} + /* This function requires the caller holds hci_req_sync_lock */ int msft_suspend_sync(struct hci_dev *hdev) { @@ -493,6 +517,8 @@ int msft_suspend_sync(struct hci_dev *hdev) /* All monitors have been removed */ msft->suspending = false; + msft_update_filter_enable(hdev); + return 0; } @@ -633,6 +659,7 @@ int msft_resume_sync(struct hci_dev *hdev) hci_dev_unlock(hdev); reregister_monitor(hdev); + msft_update_filter_enable(hdev); return 0; } @@ -670,11 +697,11 @@ void msft_do_open(struct hci_dev *hdev) if (msft_monitor_supported(hdev)) { msft->resuming = true; - msft_set_filter_enable(hdev, true); /* Monitors get removed on power off, so we need to explicitly * tell the controller to re-monitor. */ reregister_monitor(hdev); + msft_update_filter_enable(hdev); } } @@ -706,6 +733,11 @@ void msft_do_close(struct hci_dev *hdev) kfree(handle_data); } + /* The advertisement filter is back to its default, disabled state + * after power off as well. + */ + msft->filter_enabled = false; + hci_dev_unlock(hdev); mutex_lock(&msft->filter_lock); @@ -1173,6 +1205,7 @@ static void msft_le_set_advertisement_filter_enable_cb(struct hci_dev *hdev, int msft_add_monitor_pattern(struct hci_dev *hdev, struct adv_monitor *monitor) { struct msft_data *msft = hdev->msft_data; + int err; if (!msft) return -EOPNOTSUPP; @@ -1180,13 +1213,17 @@ int msft_add_monitor_pattern(struct hci_dev *hdev, struct adv_monitor *monitor) if (msft->resuming || msft->suspending) return -EBUSY; - return msft_add_monitor_sync(hdev, monitor); + err = msft_add_monitor_sync(hdev, monitor); + msft_update_filter_enable(hdev); + + return err; } /* This function requires the caller holds hci_req_sync_lock */ int msft_remove_monitor(struct hci_dev *hdev, struct adv_monitor *monitor) { struct msft_data *msft = hdev->msft_data; + int err; if (!msft) return -EOPNOTSUPP; @@ -1194,7 +1231,10 @@ int msft_remove_monitor(struct hci_dev *hdev, struct adv_monitor *monitor) if (msft->resuming || msft->suspending) return -EBUSY; - return msft_remove_monitor_sync(hdev, monitor); + err = msft_remove_monitor_sync(hdev, monitor); + msft_update_filter_enable(hdev); + + return err; } int msft_set_filter_enable(struct hci_dev *hdev, bool enable) -- 2.53.0