Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1273483rwi; Mon, 10 Oct 2022 13:56:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4K1KCDc74kvScbipkoZ/D8Hfl2WkhKfovfMAbCO34TTFPbNMNoncQgUUH7IzTurTGmloV6 X-Received: by 2002:a65:5b05:0:b0:439:a0ae:7e6a with SMTP id y5-20020a655b05000000b00439a0ae7e6amr18380777pgq.16.1665435389659; Mon, 10 Oct 2022 13:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665435389; cv=none; d=google.com; s=arc-20160816; b=qg38ExG9EokhuraIesQi1xpHq7hLmVA3xg1cwHh0tytFmx2+u/6IeZ/Kii1SZDbdjU a0E6asl2ZID3x6OuSIag3/eHB2HkL0dVOk7yjliCZE2OW7Rqx/XleKvTH3maO0aXNXST V5jxS3Zp2hxN4Aq8CjMahflesExzYmfVJEBX+URyUgCKhD+6FXosS4U3h4Mj0HKRykRt h9qbbrtT/u4poGl4EeEUDY8rkP1YPmuXIonmrd3BOZKMjVw0SHDxcwVMOCwThPiAf5+R pdraXdGhx2IsBjJttuNfmuqQ1c6CThKmKkEDYgio/sPkdcSdoYeTn/1WEtxbPYYGHmRP t9gA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=wAxJvpKCbPEYRAA5DTehKI2/TiHRvd/tHR57hlacWyA=; b=MgPsmTwc5AeJ4T4x7TphEQhP2wBIybO3EeagsV7musyc9F+W8FNKp9uKfWkBiT1r/b v5vERowxJj0wFyd67P1ZXbAydjm69DwluP9k8IE1ESv7vtYAmQNZzvgxaFiPTGlfKLf8 jPvICjqRDoScFqLTBvhqJdJP8eq/0CVFYPrqn5SsebBSmSAyR11p9Pu8ZWjcbnE48KTM ytTc/0VADJrIVPiKT3kLP0RDxqD5ODgZfHnQ1cin3LjzMUKOgd1mdFzOVrbPa0Mb1k3y 3Jm0a26LU9jWpqHyrP0u7b8/IPEMcROXrYH4T9yUzGxAjmi6ZEk+CZa8gr2rdFEAsS5R ViRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n8YDUpah; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m20-20020a637114000000b004402f48dee0si13035924pgc.629.2022.10.10.13.56.06; Mon, 10 Oct 2022 13:56:29 -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=@intel.com header.s=Intel header.b=n8YDUpah; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230170AbiJJUhM (ORCPT + 99 others); Mon, 10 Oct 2022 16:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229958AbiJJUgg (ORCPT ); Mon, 10 Oct 2022 16:36:36 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FD137EFFA for ; Mon, 10 Oct 2022 13:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665434130; x=1696970130; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=pgXwzFPx2tJhStAb9dugB7qWHfF5mmuTgdrd5/SwxlE=; b=n8YDUpah3/WLTexGufTd2zaw8fOlT2Bc8YAjgYnGzyVgrtqJksCpYBdE ZpW1PROEtjdrXv8CU32afpAgSjCJ7mGWRMyvZDfZ4Kpy2xS6PCpS+LfVW jSOI/VPKuE17RPUSjzY4HFJNnCLla6KvwXa/egMqkwCRDEunqEuZu/MIf Veg/lJMTirGCfJ+EZlkpQXRe7ekoJ4+JGGGWBS+nxJHcOCCm+5NqPwT4Z Fc18iGXRcmRieoeO8uxTK/SRcBHi8XKr83IwG6hukLXG7au25izDAaMa5 lGR4NNcj5D2WwXmev3fnRDi8EbLAFgfNSk829fVp+H2sNMwdSm1infOEf Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10496"; a="330802908" X-IronPort-AV: E=Sophos;i="5.95,173,1661842800"; d="scan'208";a="330802908" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2022 13:35:30 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10496"; a="730696017" X-IronPort-AV: E=Sophos;i="5.95,173,1661842800"; d="scan'208";a="730696017" Received: from yvasudev-mobl.amr.corp.intel.com (HELO bgi1-mobl2.amr.corp.intel.com) ([10.209.135.7]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2022 13:35:29 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, brian.gix@intel.com, Luiz Augusto von Dentz Subject: [PATCH 1/2] Bluetooth: hci_sync: Fix not setting static address Date: Mon, 10 Oct 2022 13:35:21 -0700 Message-Id: <20221010203522.1251151-1-brian.gix@intel.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 From: Luiz Augusto von Dentz This attempts to program the address stored in hdev->static_addr after the init sequence has been complete: @ MGMT Command: Set Static A.. (0x002b) plen 6 Address: C0:55:44:33:22:11 (Static) @ MGMT Event: Command Complete (0x0001) plen 7 Set Static Address (0x002b) plen 4 Status: Success (0x00) Current settings: 0x00008200 Low Energy Static Address @ MGMT Event: New Settings (0x0006) plen 4 Current settings: 0x00008200 Low Energy Static Address < HCI Command: LE Set Random.. (0x08|0x0005) plen 6 Address: C0:55:44:33:22:11 (Static) > HCI Event: Command Complete (0x0e) plen 4 LE Set Random Address (0x08|0x0005) ncmd 1 Status: Success (0x00) @ MGMT Event: Command Complete (0x0001) plen 7 Set Powered (0x0005) plen 4 Status: Success (0x00) Current settings: 0x00008201 Powered Low Energy Static Address @ MGMT Event: New Settings (0x0006) plen 4 Current settings: 0x00008201 Powered Low Energy Static Address Signed-off-by: Luiz Augusto von Dentz Tested-by: Brian Gix --- net/bluetooth/hci_sync.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 76c3107c9f91..b53bb0ee9d39 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -3054,6 +3054,7 @@ int hci_update_name_sync(struct hci_dev *hdev) * Enable Authentication * lmp_bredr_capable(Set Fast Connectable -> Set Scan Type -> Set Class -> * Set Name -> Set EIR) + * HCI_FORCE_STATIC_ADDR | BDADDR_ANY && !HCI_BREDR_ENABLED (Set Static Address) */ int hci_powered_update_sync(struct hci_dev *hdev) { @@ -3093,6 +3094,23 @@ int hci_powered_update_sync(struct hci_dev *hdev) hci_update_eir_sync(hdev); } + /* If forcing static address is in use or there is no public + * address use the static address as random address (but skip + * the HCI command if the current random address is already the + * static one. + * + * In case BR/EDR has been disabled on a dual-mode controller + * and a static address has been configured, then use that + * address instead of the public BR/EDR address. + */ + if (hci_dev_test_flag(hdev, HCI_FORCE_STATIC_ADDR) || + (!bacmp(&hdev->bdaddr, BDADDR_ANY) && + !hci_dev_test_flag(hdev, HCI_BREDR_ENABLED))) { + if (bacmp(&hdev->static_addr, BDADDR_ANY)) + return hci_set_random_addr_sync(hdev, + &hdev->static_addr); + } + return 0; } -- 2.37.3