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=1796383440; b=wDB2VAb3e4rB3OxmK3jekgQJB2dDKFAcNy7bEuC/P3NTrTDIycWAoQdKJoWloFzq81sA FxgvrwKJactrhxUl4CKHz70fzq9Qwb5pZuFnMaMGMT8Vvk3f8EymWmAfG5XcZU4zF76FD HRYZSzEpUr1jVAN4p+NJEGvcDmBmyMnv/Lzwaae+uuyIKNbqy6JKHrTeP2t/ckfeo/rUu 2jJScqW25BJnSj9k6si2k+CIQHNpSMeO/OegVMEcZz7S9xxRJ5LBrrg7Su//tmVmVXchH EnT0mBh0lnkFgAcbe6zjx8bobpntkRVVR3M+hUDwrVvAmHWRO3HshYuxKCc88/qcMsw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383440; 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=0SMFxZez1G3dkTGlu2EDFNoWqOhYjy6EEbuSliT1bgg=; b=Xlr4t8B1d79tlZXzOUa37EqEmFBB+OPGncbWTRMIkurl+eeoG+zRqLl/hvytGtR16Cxl 4q2lZC/Y68nLtUBwHqFMB8kKFqfI4ELFUD3myuVj3qsbEU0JixlpqZ7i8rxsAZfiGWWfx XD8Ml8oWHGpngduZLcIH3wQNQJKEaXjH7cEjl6Ku3io69ChV5YdhdWAGczwkO7k+gjTLR bPQzN0l9r+BKYi5Ikvwodqpe+q3/xel//SMHyvvIbD/6sxDnNQc6mB+csTf1H3KstMUSM uwEJqyjOfkyfqnG5CW4/gF/ApltxuyjSzZBlEJOZqlZLIDFUyNvVohyVIfX0ogyUOQw== 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=rKf3MIOK; 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 20D6B60A380D; Fri, 4 Dec 2026 11:23:59 +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=rKf3MIOK Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4D211F00897; Fri, 4 Dec 2026 11:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383439; bh=0SMFxZez1G3dkTGlu2EDFNoWqOhYjy6EEbuSliT1bgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rKf3MIOKlXvWWiDEOIdImLO19pcPvygxd17m5j0qQok4E5Zo6JwgUhvMOcUODteOX oV5bHxl/rj1xmVZJpF4ii7OAEvk2RyaDi/gck61H9DaiFlTEyF4nureidkL0Y/ZgRD mltSfD99THwqYv+8eUgoLMjLa26J8UdT1Tza7g6k= 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 6.12 224/555] Bluetooth: MSFT: Only enable the advertisement filter with monitors Date: Fri, 4 Dec 2026 19:04:27 +0900 Message-ID: <20261204100617.581125565@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-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 e4597763e06c6..caec2869249f4 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