Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3443320rwd; Mon, 22 May 2023 13:59:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4cYstNWfauGU/J4w52naRoS/sPrmcO3bcW+nsbmizxmZ3L/0NomX3C4+2UAJCHcfEN/TwQ X-Received: by 2002:a05:6a20:9d92:b0:107:1f60:3edf with SMTP id mu18-20020a056a209d9200b001071f603edfmr10109358pzb.61.1684789150623; Mon, 22 May 2023 13:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684789150; cv=none; d=google.com; s=arc-20160816; b=LtHIwS8ytOHORbklVpZKw2geORwsTIBs488MAV4eZbxYGEaXU2/Z5IDZRBdQu95bab Nx+NZ6kIOD6m97exh0owXOVU/5RDob0TpmLLkRWHLKU9WwrKZsrfBdr0gbAJAEtvezz0 8zGzmVkeX+1pJ2Nwq76c7Qr3BCNLV6y/hLnISz62aOvtNpHOCIEKbhc5u0fM0B1nRbUy ev+x8KGOkitspZWm4aFoOSJyFfgtmPZSBhUzJmd6zqHZXzQtDmHfHoEkJNUvCFFUhnbC UhsZhXkKdzmer5T2TvhwRMDMnl0uk/bPEnz01niAdZaTHpnatiiyxgPrn9aoDXhu75u8 68pw== ARC-Message-Signature: i=1; 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; bh=4EqcbStNCK7WoJujGbP2Bn9LD/4oCgRBuOjglwHK0QE=; b=thO3pb+4sBBJ/V7jTyz1mbwXqzK03brzI+FevMc2h06ZOWnIg66m9RsW3NlcnG8gcS rFjlPJofJQH6vO9cH9U5O+2ifcjOlBHq0x0xGo5cI2+pDeYrgaxqtFhOKfuyB1tO39xu nV6YAxLb+TUL9+jS266cM5F9G3H9g5VIt9Nc7WRWl3bmh/VMo8dgp92CZ2oPKLxfSjch ILtDOCs2Qkw75+0jNpKZhAza+gl7U3N1WhLSveakhIWEQM/Xm7XJjDnlJGYZibNmsZ/S JP+M9pXJPqy2nNoI/OsldFPdyqgbQ6t27zIpJHaAsp5ZlWvfdU30NwAliXEepzboPaFG HIYg== ARC-Authentication-Results: i=1; mx.google.com; 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 24-20020a631258000000b0052c6b5537easi653435pgs.47.2023.05.22.13.58.34; Mon, 22 May 2023 13:59:10 -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; 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 S234521AbjEVUwy (ORCPT + 99 others); Mon, 22 May 2023 16:52:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231860AbjEVUwy (ORCPT ); Mon, 22 May 2023 16:52:54 -0400 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E610B7 for ; Mon, 22 May 2023 13:52:52 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id C68C2240027 for ; Mon, 22 May 2023 22:52:50 +0200 (CEST) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QQ8m110S1z6tvv; Mon, 22 May 2023 22:52:49 +0200 (CEST) From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH v2 2/2] Bluetooth: ISO: fix CIG auto-allocation to select configurable CIG Date: Mon, 22 May 2023 20:52:45 +0000 Message-Id: <47604dd334647dcd097dc0a87814745790522b0d.1684788145.git.pav@iki.fi> In-Reply-To: <2bf70b0560375b50180518968abd8c4dfcce7f34.1684788145.git.pav@iki.fi> References: <2bf70b0560375b50180518968abd8c4dfcce7f34.1684788145.git.pav@iki.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NEUTRAL,T_SCC_BODY_TEXT_LINE 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 Make CIG auto-allocation to select the first CIG_ID that is still configurable. Also use correct CIG_ID range (see Core v5.3 Vol 4 Part E Sec 7.8.97 p.2553). Previously, it would always select CIG_ID 0 regardless of anything, because cis_list with data.cis == 0xff (BT_ISO_QOS_CIS_UNSET) would not count any CIS. Since we are not adding CIS here, use find_cis instead. Fixes: 26afbd826ee3 ("Bluetooth: Add initial implementation of CIS connections") Signed-off-by: Pauli Virtanen --- Notes: * v2: add forgotten signoff + fixes It could also make sense to always auto-allocate to an unused CIG_ID instead. However, that changes current behavior, and would force userspace to do the allocation themselves as they may want to use as few CIG as possible. I think e.g Intel AX210 doesn't support multiple CIG. With the patchset adding new BlueZ iso-tester CIG tests: ISO Connect2 CIG auto/auto Seq - Success Passed 0.148 seconds net/bluetooth/hci_conn.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 2363477af89d..99150d054a8d 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1771,24 +1771,23 @@ static bool hci_le_set_cig_params(struct hci_conn *conn, struct bt_iso_qos *qos) memset(&data, 0, sizeof(data)); - /* Allocate a CIG if not set */ + /* Allocate first still reconfigurable CIG if not set */ if (qos->ucast.cig == BT_ISO_QOS_CIG_UNSET) { - for (data.cig = 0x00; data.cig < 0xff; data.cig++) { + for (data.cig = 0x00; data.cig < 0xf0; data.cig++) { data.count = 0; - data.cis = 0xff; - hci_conn_hash_list_state(hdev, cis_list, ISO_LINK, - BT_BOUND, &data); + hci_conn_hash_list_state(hdev, find_cis, ISO_LINK, + BT_CONNECT, &data); if (data.count) continue; - hci_conn_hash_list_state(hdev, cis_list, ISO_LINK, + hci_conn_hash_list_state(hdev, find_cis, ISO_LINK, BT_CONNECTED, &data); if (!data.count) break; } - if (data.cig == 0xff) + if (data.cig == 0xf0) return false; /* Update CIG */ -- 2.40.1