From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796336064; b=h3dWm7Odmg1gF/Q1CIK5NsuDOLFrAA8MqdifQOblJsnWRE10OpdPGuISbtRO22Zqt5Iv 2bsJ6QaYjltBkANvd5nAcoSgM4YBMmAThUhe6jfalM8BymwRc0cSy4eOg2gSNed00Uj/u +3/wFCYFK1e83P87lgXQHkmZz/fSJ0XoiOrLw2Y7wQCBQj4kfa0qIRFzFnbeXZYo+PqDS 0husbgkehxyE/SuBAIiCECLU4EFLPe8VHG0uUy8gbOMGfYhRKxspgQLGFBm6PD8AWqL8c 29+m85CAZ//FI9X4wFRgkdRDFGB9fhX6b+Id5tAhZ8spNhpBhN4Bmh+gbmbvo7RjRrg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796336064; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=/Ls0xMYqfJlulIBb5N0haaMJpfPPFexiWavKE1/gVqs=; b=O97CMBHqFLtaz0LkgTfjfemd4s7q87TGkfmEjcAQtQkFjTSQOGM3Ope2F+7/mVJpAZ5w zhXBHV3MYfYSJi8FzCmJbMJxSSQVFpyymmVr0m0HnS1qoKOZIJNmoNUYq6NyFJEoD21TE zPnuGEEYZOG6xdxYX6MEGd56THWXXQTt3dGHmDpWC3W/8I9SuK/dWDnBKD4dsrO6xEMzE /6xXz5eHeJ4+/cs2V7GzgnDUvQZ0vkyWPKjz/zAARBRuGWR/JYDbgbb2GW6PpqQHMD4DF N+UZ56PZN7LTiw/cmdiqFDG/nqPbFC6Hm+3YIrXFqwxb3UxmZiaZcTstKVkSZBuWAQQ== 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=TgiLOFH8; arc=none smtp.remote-ip=209.85.128.51 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 0BA7E606A33A for ; Thu, 3 Dec 2026 22:14:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0BA7E606A33A 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=TgiLOFH8 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4bb72b6e1b2so232485e9.2 for ; Thu, 03 Dec 2026 14:14:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796336062; x=1796940862; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/Ls0xMYqfJlulIBb5N0haaMJpfPPFexiWavKE1/gVqs=; b=TgiLOFH89dYpFfrI87v5Y/e05H56DRpiY0hRYYJCwa/YyggszxABYBY9nKZfs+mayg 6WJnOS+EjtV/naZMF0mXgHkQ4qw1AkqVRhIppCVVGFkdVKz6A13c8r8gppLMpq1dZYqW r8ab1doZ2wRQ7ZCVjC8ySABlZsMPDfJSVz4XCDY/7iV/uoDPDGXDbQCBUCWTGKO08I4l ck1cbJaizLkdPQ2hmFAdwfk7uSTSxDUNE1f7FPCJNXLPWUwIolIyhHV7zoLJy8mkInA+ c/KYd5a9/uDJtDKHciHm751KkcWU0DUJFnUa9gCUSVM3CUioHyljoifPzaXLFhEvsqpU kjYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796336062; x=1796940862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=/Ls0xMYqfJlulIBb5N0haaMJpfPPFexiWavKE1/gVqs=; b=aILZbmRVoiUeWPzQh8AjJ11Tr6T1HW8ubnufZbuSspzxvAxv35rAnto93oGw4yPsqO MwD24gfuUcv1x6S9b1g65zoygZrInCwldQiD2Eo/d2pc0eMhZsR4qlsa4//y09rOqoee por2UfDdrGTYcpAWV3Wnyshn7x6DJyMwxvsEh1nFZBAV48DAAyyPfLs5BUIIE8VIua4Y S7m+84bbOJsujnx4UgGuUV/dJe9i9++pRf4SoGvzVrg3btoWJ794HvCNu/Lov7rNro2Y nwh10ru0KODIaMjMSLhBNOI54i+gypwOnIyBX2qzjEuZDQPTouD4BJtYglhyUmcKLbzd rXdw== X-Gm-Message-State: APuU4Z8EsuOA6/KfAGIRLIm2OqgVedMa+hwiHPPVo8RGJI2Fdj/0arKe D7U31J8ij6bjnEawDkiZY8JInShUYwFZX+7bwfowyr5Kfo24tpJckrGVnz4mvfw3 X-Gm-Gg: AZFdTZerQ6yx7Uc5ureFUpS9G3q1CGEbPU5M+RaZJyN1XBfxtSY0rajJZcJJIvCei5b rWG54+nVExkqT3tIVy6dI1n+uYectVHw2SpP7kY3N4yvD3dnhSSEy/9xGEfJrZnG9zTxTPw3Ge3 6ConKBWK9G16AH4Oqbnx03MAjzMCRxspzBzTKJPjlR2vHadAK+mEX/iyjRU5Y1pB6wbyZL57L86 LIyDRLyNKDhmC6IiXEBiu6iOUrVnu2YJrO6pCAeWgfiMvxbE6Gc0wfPJrliZRayrUlFZcadOfmS PJj061JC6eH9d4p8sTPR1fr96nIJD1z90b2VtQS3rlamL5RefqFty/MYzcfXBQ/hyT6Qr4oMHRG WBVGRKVSaoXT7d7V7dR90cmW5mND5suK+URmC4ZAzE/+Hi8419SyePOhNHa8n4W/cxQwUqzfBau 4gwaB6Avx/Xca3B3GX/d/g5hq3GuEvvlHPcUMSVn/eH3h4TJlW9pQJJNUXBMFiKitpj9MJsGpLU ResZKRFJjpRposOMvUb8uWcOtUVzHe3UPBZfoQ5lJD/aZI7/imGniAlUDnxuGyyu5Ir1tYk5TfJ IeVhUbbwuEDcgY3Jj/E4IVOT/hytaWMnEumHbEyjl0cLEojO X-Received: by 2002:a05:600c:4595:b0:4bb:bf7e:e264 with SMTP id 5b1f17b1804b1-4bbeb84f7c6mr725045e9.2.1796336062514; Thu, 03 Dec 2026 14:14:22 -0800 (PST) Received: from schinder.fritz.box ([2001:9e8:b39a:7900:a13b:fe74:8c9c:c788]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe00df154sm117266225e9.14.2026.12.03.14.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 14:14:22 -0800 (PST) From: Roland Schober To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, Roland Schober Subject: [RFC PATCH v2 3/6] Bluetooth: hci_event: Stop PA when an advertising set times out Date: Thu, 3 Dec 2026 23:14:02 +0100 Message-ID: <20261203221405.682222-4-rolandschober1968@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261203221405.682222-1-rolandschober1968@gmail.com> References: <20261203221405.682222-1-rolandschober1968@gmail.com> X-Mailing-List: linux-bluetooth@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 An advertising instance can have a timeout, which the controller is given as the duration of the advertising set. When it ends, the controller sends LE Advertising Set Terminated and the instance is freed. The controller only ends the advertising of the set, though: the set stays, and periodic advertising on it goes on until the host disables it. For an instance with periodic advertising this leaves a train which nothing stops any more, and LE Set Periodic Advertising Parameters is refused when the instance is added again. Remove such an instance with hci_remove_advertising_sync() instead, which disables periodic advertising and removes the advertising set before it frees the instance. Assisted-by: Claude:claude-fable-5-2 Signed-off-by: Roland Schober --- net/bluetooth/hci_event.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 749963d0ce77..8f4a9c261985 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -6674,6 +6674,13 @@ static struct adv_info *hci_le_ext_adv_owner(struct hci_dev *hdev, u8 handle) return NULL; } +static int hci_le_ext_adv_term_remove_sync(struct hci_dev *hdev, void *data) +{ + u8 instance = PTR_UINT(data); + + return hci_remove_advertising_sync(hdev, NULL, instance, true); +} + static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, void *data, struct sk_buff *skb) { @@ -6705,10 +6712,22 @@ static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, void *data, if (!adv) goto unlock; - /* Remove advertising as it has been terminated */ instance = adv->instance; - hci_free_adv_instance(hdev, adv); - mgmt_advertising_removed(NULL, hdev, instance); + + /* The controller goes on with the periodic advertising of a + * set whose advertising has ended. Stopping it and removing + * the set takes commands, so the instance stays until they + * are through. + */ + if (adv->periodic && + !hci_cmd_sync_queue(hdev, hci_le_ext_adv_term_remove_sync, + UINT_PTR(instance), NULL)) { + adv->enabled = false; + } else { + /* Remove advertising as it has been terminated */ + hci_free_adv_instance(hdev, adv); + mgmt_advertising_removed(NULL, hdev, instance); + } list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { if (adv->enabled) -- 2.47.3