Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp434567pxu; Wed, 25 Nov 2020 06:57:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFKW9mUurgfrLCgenqM1PZFvesbqBh7ot8+pFfXiQWRwMJOFgaEmjQ/BZfuK6RZGyzJXfG X-Received: by 2002:a50:e443:: with SMTP id e3mr3857147edm.160.1606316253310; Wed, 25 Nov 2020 06:57:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606316253; cv=none; d=google.com; s=arc-20160816; b=a65IyVkXsCdfFw5IalkUc0eoc6N9p5K2Jw4YkqRPvWZzN6u6tcS2czvT6mZvrlC1Vt UWNbLWKIPImYaVAX10xealma9yn/tjd0cTMarso3VdFmBgClqP5rAC+jVelqq8xsnrIk o7WGbYethumcAEgb3gg9cKbdlo9sMMQixNbK6AnzdURSpSJh/CtWQpVxTWBnA/dqlVKv v0eZ2HEhNSp4WkwdHWxyEur6qKEXNZ6xTSw1ThBQFYiaVe1Phs49iU84NnUAJJ7lQT7/ 4McjhTId58Nh/8JAlm+ZfLAcvbh83GSYVmzbtDpqK3pwO7pPXXE6nz1M8R+RiaVc3x6P ETvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=ThBm74vBGqxtNesyHUS36np3DMyoA2BtWrV6lml2OgY=; b=s/a0LgnWl3uxBDIzpmOF8DoezTlGRyg09HNwjG8p2vYw/YfZCi6G7hXy3FKtUbdamA g4maDUnh5/ys0/IdSbm/agdm8+35+nBm3Z/NS5w3mmZ9kerq5C+0TO0fa5GdnZDMaHqI jpekr687Kh8PS49KehzCvIKZyq+FTc1qosovRLfHo/EDeuoeF/7UkDoVnHZlFB6m8mtc KKiIXN0LBGQm7j9hQuLCEiZhYnrN86YidioVSX5Bc2nmC9TodMUaViekXrGZN6EiYsLh 29OeYe9cjGyb1jWg0/58a8BV9SE/ulrZiDbD3Kq58DeEDaHGU/dMjYHZzCA09HyVADR4 DBCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d64si1358442edd.257.2020.11.25.06.57.08; Wed, 25 Nov 2020 06:57:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729472AbgKYOnN convert rfc822-to-8bit (ORCPT + 99 others); Wed, 25 Nov 2020 09:43:13 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:49479 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729356AbgKYOnM (ORCPT ); Wed, 25 Nov 2020 09:43:12 -0500 Received: from marcel-macbook.holtmann.net (unknown [37.83.193.87]) by mail.holtmann.org (Postfix) with ESMTPSA id D3B33CED08; Wed, 25 Nov 2020 15:50:22 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.20.0.2.21\)) Subject: Re: [PATCH] Bluetooth: Cancel Inquiry before Create Connection From: Marcel Holtmann In-Reply-To: <20201124010906.340433-1-sonnysasaka@chromium.org> Date: Wed, 25 Nov 2020 15:43:09 +0100 Cc: BlueZ development , Abhishek Pandit-Subedi Content-Transfer-Encoding: 8BIT Message-Id: <92C0EFAB-EDF1-4EDB-ADE7-FF734928C8AE@holtmann.org> References: <20201124010906.340433-1-sonnysasaka@chromium.org> To: Sonny Sasaka X-Mailer: Apple Mail (2.3654.20.0.2.21) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Sonny, > Many controllers do not allow HCI Create Connection while it is doing > Inquiry. This patch adds Inquiry Cancel before Create Connection in this > case to allow the controller to do Create Connection. User space will be > aware of this Inquiry cancellation and they may issue another discovery > request afterwards. > > Sample Command Disallowed response of HCI Create Connection: > < HCI Command: Inquiry (0x01|0x0001) plen 5 > Access code: 0x9e8b33 (General Inquiry) > Length: 10.24s (0x08) > Num responses: 0 >> HCI Event: Command Status (0x0f) plen 4 > Inquiry (0x01|0x0001) ncmd 2 > Status: Success (0x00) > < HCI Command: Create Connection (0x01|0x0005) plen 13 > Address: XX:XX:XX:XX:XX:XX > Packet type: 0xcc18 > Page scan repetition mode: R2 (0x02) > Page scan mode: Mandatory (0x00) > Clock offset: 0x0000 > Role switch: Allow slave (0x01) >> HCI Event: Command Status (0x0f) plen 4 > Create Connection (0x01|0x0005) ncmd 1 > Status: Success (0x00) >> HCI Event: Connect Complete (0x03) plen 11 > Status: Command Disallowed (0x0c) > Handle: 65535 > Address: XX:XX:XX:XX:XX:XX > Link type: ACL (0x01) > Encryption: Disabled (0x00) > > Reviewed-by: Abhishek Pandit-Subedi > Signed-off-by: Sonny Sasaka > > --- > net/bluetooth/hci_conn.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c > index 4f1cd8063e720..b41ad08f8d411 100644 > --- a/net/bluetooth/hci_conn.c > +++ b/net/bluetooth/hci_conn.c > @@ -233,6 +233,17 @@ static void hci_acl_create_connection(struct hci_conn *conn) > else > cp.role_switch = 0x00; > > + /* Many controllers disallow HCI Create Connection while it is doing > + * HCI Inquiry. So we cancel the Inquiry first before issuing HCI Create > + * Connection. This may cause the MGMT discovering state to become false > + * without user space's request but it is okay since the MGMT Discovery > + * APIs do not promise that discovery should be done forever. Instead, > + * the user space monitors the status of MGMT discovering and it may > + * request for discovery again when this flag becomes false. > + */ > + if (test_bit(HCI_INQUIRY, &hdev->flags)) > + hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL); > + while this seems acceptable, what happens when we have interleaved discovery where we toggle between BR/EDR inquiry and LE scanning. Are you sure we not better cancel the mgmt discovery completely. Regards Marcel