Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3525529rdb; Wed, 27 Dec 2023 10:04:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFu4+KqH2mG2I+fA8Bk+CCCcMoAZg3Cc+FmckL5atCCHVgweYORXTtlRtfKRk9iP1NaTv+p X-Received: by 2002:a17:90a:f30e:b0:28c:934a:2e7d with SMTP id ca14-20020a17090af30e00b0028c934a2e7dmr1198276pjb.6.1703700293436; Wed, 27 Dec 2023 10:04:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703700293; cv=none; d=google.com; s=arc-20160816; b=uJn96YAZrfLW0i3ty17x3KFpjSEvdH5R+d+44JrmWe2mqifzBQMBCWDJiaNgMRuzfX 4UsKQvDkV6cmgXkpRbPGlY3+La3hiao7q3fqnX2oy48g9Jsvb2VOWEdC7DJdls89/toH 68TDyfZSo38IMR8aqUlGlxnMUN3huf9tC4dgNCDBErRh+IfYYC26yQRRM6z88uSGukru hg3gKZtbN8ruWQluI9iBqv7cSI9X5nHVgsi/g7D76bEilaStqfQXz+T4znAaKVIOduGW +TURm6jGT2LoE8hkfhbuyErVu7TxKLp3yETu+zV32qsOTDIAFT24ZDLogdOAlYpjQ0Cp wAng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=4u5qrCcvMhdCaF5+4+MYnREuWT6QxFRyC6uNkm1VQMw=; fh=QkA2fdtUjJ3r14NLOCiFydbWOO3juImWjSP1e0qldP8=; b=BvlE9X/L4O+atA7OiERuWHNvjaF5jjG5IZ4OEvTip9kMJpq1KO/EtsfXe9xnlluQWN eQ31j+AbbQI2w+/O4JuvLnv347V5CBZhSaW2dXqH2bxsKp7OmbJ3/fk7BKbMBBSiOcpo APF551sztWv9CiHVKHw05WfoMwvrZ32AAqWRAqs93ImPsgN5WTLELqmkVMwpUAJylStj k4VpaAGmGK5fR9lO725YLynlI5ye5CKIte9/CjGQgXB792nCp6GooJGQebcI8zZQQd8U FR1D+1y/rzh7J4tc5VWOBKLwuZrIBFuXTVrctra/IiOUIbX4gwpCr9gdOuAJjTWzVS+V 9AMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZhpGayBt; spf=pass (google.com: domain of linux-bluetooth+bounces-775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c93-20020a17090a496600b0028b6d3635a6si14469364pjh.57.2023.12.27.10.04.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 10:04:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZhpGayBt; spf=pass (google.com: domain of linux-bluetooth+bounces-775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 311B9281E86 for ; Wed, 27 Dec 2023 18:04:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50AFC4655E; Wed, 27 Dec 2023 18:04:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZhpGayBt" X-Original-To: linux-bluetooth@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A115346522; Wed, 27 Dec 2023 18:04:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10EF6C433C8; Wed, 27 Dec 2023 18:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703700274; bh=Z5Xx4Awhm2yDAU7eR4KCbbH90zyc67q6J3SQ9KIFSvE=; h=From:To:Cc:Subject:Date:From; b=ZhpGayBt8lKxIXkCy85p6bKIupO7GjLDohiqZns/nqowkDm6XfGlaj50PGSgHvQOq JhklV8O3Gk9WP227ddow0eJBwVcggrz/iZBd2aYKn6MR3VaDf1+0xdDaqZ1Qp14+KW HrRaDj6JxnnNvmDe1ysZckUpI24H3qqo4UKVq1+UocGe3mTGIa0wiWiflwuhxY3Gkk xkr3KaY9NGiBFpR5xrWkih/GDFh1u3JhZj6id/6nEZ+ZAZ2YMoxA1OihjvSnTQZCky junga5yF5xEDplOuDZArTheqGozslPGnfZ+0Aq7mezsAfU6TGgt7EG4CSryARtcjWc lmWRFG+B+wJZA== Received: from johan by xi.lan with local (Exim 4.96.2) (envelope-from ) id 1rIYGb-0001fI-1l; Wed, 27 Dec 2023 19:04:29 +0100 From: Johan Hovold To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: Bjorn Andersson , Konrad Dybcio , linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Balakrishna Godavarthi , Matthias Kaehlcke Subject: [PATCH] Bluetooth: qca: fix device-address endianness Date: Wed, 27 Dec 2023 19:03:06 +0100 Message-ID: <20231227180306.6319-1-johan+linaro@kernel.org> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The WCN6855 firmware on the Lenovo ThinkPad X13s expects the Bluetooth device address in MSB order when setting it using the EDL_WRITE_BD_ADDR_OPCODE command. Presumably, this is the case for all non-ROME devices which all use the EDL_WRITE_BD_ADDR_OPCODE command for this (unlike the ROME devices which use a different command and expect the address in LSB order). Reverse the little-endian address before setting it to make sure that the address can be configured using tools like btmgmt or using the 'local-bd-address' devicetree property. Note that this can potentially break systems with boot firmware which has started relying on the broken behaviour and is incorrectly passing the address via devicetree in MSB order. Fixes: 5c0a1001c8be ("Bluetooth: hci_qca: Add helper to set device address") Cc: stable@vger.kernel.org # 5.1 Cc: Balakrishna Godavarthi Cc: Matthias Kaehlcke Signed-off-by: Johan Hovold --- Hi Qualcomm people, Could you please verify with your documentation that all non-ROME devices expect the address provided in the EDL_WRITE_BD_ADDR_OPCODE command in MSB order? I assume this is not something that anyone would change between firmware revisions, but if that turns out to be the case, we'd need to reverse the address based on firmware revision or similar. Johan drivers/bluetooth/btqca.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c index fdb0fae88d1c..29035daf21bc 100644 --- a/drivers/bluetooth/btqca.c +++ b/drivers/bluetooth/btqca.c @@ -826,11 +826,15 @@ EXPORT_SYMBOL_GPL(qca_uart_setup); int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) { + bdaddr_t bdaddr_swapped; struct sk_buff *skb; int err; - skb = __hci_cmd_sync_ev(hdev, EDL_WRITE_BD_ADDR_OPCODE, 6, bdaddr, - HCI_EV_VENDOR, HCI_INIT_TIMEOUT); + baswap(&bdaddr_swapped, bdaddr); + + skb = __hci_cmd_sync_ev(hdev, EDL_WRITE_BD_ADDR_OPCODE, 6, + &bdaddr_swapped, HCI_EV_VENDOR, + HCI_INIT_TIMEOUT); if (IS_ERR(skb)) { err = PTR_ERR(skb); bt_dev_err(hdev, "QCA Change address cmd failed (%d)", err); -- 2.41.0