Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2276283rwb; Sun, 6 Aug 2023 14:20:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5ldItezRAyBop+N5Mw97TfxXMO8T+Wo+GNtDyTy9HRSn7MFEQwcy8zYLiHSwh7QyDqrI7 X-Received: by 2002:a05:6830:104e:b0:6b9:8ea6:f515 with SMTP id b14-20020a056830104e00b006b98ea6f515mr6909816otp.10.1691356825707; Sun, 06 Aug 2023 14:20:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691356825; cv=pass; d=google.com; s=arc-20160816; b=WaGmXlNPcUiZxGuEluwCfGXrtJ+lLJ1RQJErz95jx/6RO7KXvpc2+x8Cvye6/IzV4D A2Psxx6EYTw+37+uD64QVCQUvGkEfa9icjd7wrw4hg9CUSOgnGYAT6A60ZT/VsvqSFpp G/mReuVLTY5nib0qR6fsOQsxJ6vsP+R5bQxg+c6huWGP6ZFhshQuyCx47Qz0Nw59Heo0 sCp3Ww9xHB6h0GjZ5NCxkrnUEp3MOSuYjG1n5VBd81qCZMoO202Wlqk2STh2AApgkWNl e0UCgdhUkW6GkptR7DUG+pB8lI6bWO4n98NHVKnqx7jRs3Fr6spOrTI2V9ibTxBSBMM7 HMgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=10nB+Wh+NxCOugfbv+kTYq9QX8gX/cCaF72EnwHIaWs=; fh=raBgKoRsHCwQLc6ReOhmOoEQ+DtSaNc74fugaHBwryI=; b=q47nu4KKgu6HFvu3SVgdg/lMKwBmWQe/Bq//AZsuRHauyie7G290/yHQDI/riV6mmN uH6Pw0WmNkgNIupUWNfGFrxq7mGxWV0Fsrs86mLsjmUgMM6EV7GsMFzKQ7yQSW5zZCQ7 p2GVCED5Ncw2bla/4ghgz8FW61VPmtmciru0dFQ2nJMIRDVgQ9VnRJuBKBmCtuY7ptIC gScjolVBVr5SuUfHwirUHwuJIWH6gQLEVIDUyeFewIoqH8tQny71JkwZGxE76hzESTTd 4HPH5UuCLh1pICxpyAnOUoc52TPX3KluE1I75SY+2ixtS/AqdLhbJYgDmXv+T7FrysZl E7UQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iki.fi header.s=lahtoruutu header.b="fVFMv8/I"; arc=pass (i=1); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 14-20020a630f4e000000b00564a191d7fesi4530977pgp.361.2023.08.06.14.20.03; Sun, 06 Aug 2023 14:20:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@iki.fi header.s=lahtoruutu header.b="fVFMv8/I"; arc=pass (i=1); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229649AbjHFUU2 (ORCPT + 99 others); Sun, 6 Aug 2023 16:20:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbjHFUU0 (ORCPT ); Sun, 6 Aug 2023 16:20:26 -0400 Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01D261725 for ; Sun, 6 Aug 2023 13:20:24 -0700 (PDT) Received: from monolith.lan (unknown [193.138.7.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4RJrRV2jCJz49Q64; Sun, 6 Aug 2023 23:20:22 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1691353222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=10nB+Wh+NxCOugfbv+kTYq9QX8gX/cCaF72EnwHIaWs=; b=fVFMv8/Imgj9FTxS80i1ntn1iIWjJhbOnbl2iJezkdv4kUz8g/Aqr/rk94f1Cf4rBpARf0 +ZiwEB4AT5NKy1h+/hhwG3UXv7m++fSUkmVhWIzeQjM2Z0UPpv/589Niquncduy2RGTlgL aUKMHqqDLy8TqL2F1P9LVa4pzVIwkePGZAcfUyTamrb1rubV5Pvrykgv3jKLX8S719yBUR TMRp0lIsnBrMZH6oIFcU9wPlp34BapOvKBByrAlcdjHvT2QqnLa2gHU5/QsEwGqAc/NHyu HmoCyfQ9vvn/2hnhq3Nkz59MW8Y2r4IwMh7CskHRd0Opu/rI01GWli2aZ2U5+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1691353222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=10nB+Wh+NxCOugfbv+kTYq9QX8gX/cCaF72EnwHIaWs=; b=eiuxaP1pP94HHk4YeJWYIwLGvVbq/MGkSOZqWwCTdorYFS/AU9knTVri2D4ENChOPK4eVl oUZlwJXLqy3s5CssME9wgXEiOiv6NMx6rDaVqgY6iwyH7+GvFr7JOneqhe0Jdzy37B8wgG B+Y0+Er1c16W6TCsvt1J9c9dtf7KNoJDFclJpsV92zj7VnOPsvOFVVw0HMhNogxQyDhjto 8nH0tpsKdVCuDNZIWNlRA+Nk8RnqIrIxqy5Fkpeg+QIHy1APr49tACKNS08xfT5wsTPQVQ MLtbGQlO/7TuYXuXdybmc2z/21QXnVlQ2B01y1vcZcs0IksQBZcQ0kGpcxukoQ== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1691353222; a=rsa-sha256; cv=none; b=fGIf3+/UhkaLsk7fHk5CKpy8aiBnR1cw3AdIiXj0qV96ihR5Ww5BPcyjHpxEaffVVHmKlV 0E3cK1cOxiohDm5JJ4ojXNbMsp+O6TxBdFupc42gzkjoHM/SaemZfSQqB1vTX6LyuZTjhc 6AXzR3vrgnsnNq8c7ZhkK/OMsvs/Yu7L8yvY8ttsHscVnxZRw8YYqbYgpE1xsOg7oXIaEq NO82EFPseTSmFi167z8TDHWeJ8mCrU6D6/du+0ptcLGWFTiJ6ixJDRhZrA4Iuz+l7bAhBh MWuRwxPO9X1M4ORTkmUb2aiMKseD/7YMUUmg6stk/YJUeoWCRUNM6J6p3reMHQ== From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH v2 3/4] Bluetooth: hci_sync: disconnect linked connections before parents Date: Sun, 6 Aug 2023 23:18:39 +0300 Message-ID: <89fd73eb453f951438c594222828aafe8e4640a3.1691352503.git.pav@iki.fi> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org SCO/ISO connections are disconnected implicitly if the ACL connection is gone. If we disconnect ACL first, controller may error disconnecting ISO/SCO, which in hci_disconnect_all_sync fails powering off. With ISO connections present, powering off usually fails because of this. Fix by aborting linked connections first in hci_disconnect_all_sync. Signed-off-by: Pauli Virtanen --- Notes: v2: new patch net/bluetooth/hci_sync.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 228259f44815..a476594ecd2a 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -5435,10 +5435,26 @@ static int hci_disconnect_all_sync(struct hci_dev *hdev, u8 reason) do { conn = NULL; list_for_each_entry_rcu(c, &hdev->conn_hash.list, list) { + struct hci_link *link; + if (c->abort_reason == reason) continue; conn = c; + + /* Abort linked connections first. Disconnecting ACL + * implicitly disconnects SCO/ISO, and controller may + * error commands disconnecting them after ACL. + * (See Core v5.4 Vol 4 Part E Sec 7.1.6) + */ + if (conn->parent) + break; + list_for_each_entry_rcu(link, &conn->link_list, list) { + if (link->conn->abort_reason != reason) { + conn = link->conn; + break; + } + } break; } if (!conn) -- 2.41.0