Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp141384lqt; Mon, 18 Mar 2024 04:11:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXcLyuf4WJrHaNe7VBMXxQMKiVAVHwIHxY+exO+3Pq9iEjyFjERteEh7tgtW5QYOgGQBVQBI41tM9N1EQft2Km+Sth9V2HP87cByJZ6ng== X-Google-Smtp-Source: AGHT+IEj/6w8LdWNFXDNcB0T/ShubVT6JpeZ08MEM0KAHz8TJVnra6JKQ9V3F4ri19SdJqApJbni X-Received: by 2002:a05:6a20:7f90:b0:1a1:8312:6dfb with SMTP id d16-20020a056a207f9000b001a183126dfbmr12440262pzj.58.1710760296282; Mon, 18 Mar 2024 04:11:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710760296; cv=pass; d=google.com; s=arc-20160816; b=QcPX+fPZqvJUPVuI2xi8FR1AZ5uRFpYADdHwdoNVTq0BXIGLP1zifaO/NTT5ZuU5T3 3TSlQDgYHYg93NxfLJJB8ZWREPgH/a7XH0fi1y0HrNKURia5Po6UCdHeTgYk/25uamwd b1weJ00I1pIGj02LFdVE4DKw8ehwu4SqyPYk4AtqZ0pZr1ShOGPvCQR4sQwvgdkx38xL 9imfDVkA2tu+RYi9NxQD3vEMkmzDrybdfAVRWDx4m9Ay3vaERH48FIGyE2CIJclhT30P /kZFEszX8VQYvoAOa8rNC1jUsVqg+V+LMZfckssL5kQbrQLvR2BpvzO8QtBOUL7m5YE4 KDSw== ARC-Message-Signature: i=2; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Xbrok+P6DEEYqsxv/lU5gLJaectgdPqLdieGjuSBF78=; fh=9CrvbGat5kbN6PjDItDegLbsiupdj8P0B5Tb4XDt5To=; b=c36pDb5LWVEfi1wmSHlWAa/gY/pj8zgKu6DJ/dvG72OXnh7jizuN9XupzGhsW6dMYw K1T6V7bk3ttMKI2i4fELEkaL9DEs1q7yiMaV6Yyoyg9iTYTo8WyhXu6AGV64mw64EAhb G57LhZrd+atZ5vc1DIWV5dzEuPvOlof3VBAgVz8ltTLAwI3pML6bWnWgvkLvkZenPI1x H5DaI615GNCYhkqjd+4thAW02F4iDYU20FSsxvB2MVZC8EBH2gpXOV0q9trDOhrW8BiM h2SiQL71/EaabkVtBRDzDZj1II8HsxTkG8LXZ/Sm/V+wbe7ymEAOoo/sQo1BdHNgX1YR D8bA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RstFvpPV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-bluetooth+bounces-2577-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i10-20020a17090ad34a00b0029c6dbdfcefsi8064142pjx.17.2024.03.18.04.11.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 04:11:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-2577-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RstFvpPV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-bluetooth+bounces-2577-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2577-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AACCAB2166E for ; Mon, 18 Mar 2024 11:10:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70F9238DF9; Mon, 18 Mar 2024 11:09:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RstFvpPV" 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 A1FFB364BA; Mon, 18 Mar 2024 11:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710760139; cv=none; b=sxzCQ85zcnlMq1BA4WqmgTs/wHUN88CfTmIjPopHbKAEf95eikCuITVhGTn3qsV+JfJBJ/v+S6/hBrUVEJu0jEGCkUVgENTd85vIUbaKD49tcwPdy9Hmgbsg6NzdzvTOidWyY8syCRYEHL5gvB/iRGre3Y9p/bwmD/B6g4GVfGY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710760139; c=relaxed/simple; bh=VQl76OihFJ6MD7Q7CC4hfGfrDaQ2DcOqSN3Z7HUNPy4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bt/HVZ+9u8h2+dp+CAsrLQEzGnrwqLILw3SEP22O1Tjry1qQRZFII53och698WW6+zQPmjuBpGkXFNy8/GaVuPupZjF8IRUAWJA1BM82EeUJMBQHsvgxsit7imZU/zd6v5Fg2eG6z6mNqHaF2UBKOXVEbq0AQDQo4VfFc9h222U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RstFvpPV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DA0DC43141; Mon, 18 Mar 2024 11:08:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710760139; bh=VQl76OihFJ6MD7Q7CC4hfGfrDaQ2DcOqSN3Z7HUNPy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RstFvpPV6fSrd69/0/PjEtpdZXRg9OeNvTe/kgTqto/4Fk8qVpZUDM9VkCwGYgk/v MrFQSwPnH+g2WO6EmFW0H3sSlF1XYFo7016p+hEu6CTsKJ9n5uB1nmWofWrjTwEv21 1R1xDrw+RYhh06fFg1vSNCdG5WIT5QtsZfBTkgf2RWaurGPeI8OnTxMgOsqzhc7xfP BGa+JR1/XDwcPECcHIbwYSWDy1O/++R0YE0xj9HE+h+4OrFYTtYrarHw0QYBT566gu YV2UavkOmmsClR4Qv7yGZkMk+TzEgi1K0jGolhsi4T2NsLQKYBL4UOQWLV+3jhdXt9 +EE0qOruf1n6w== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rmArY-000000008Jp-3iDJ; Mon, 18 Mar 2024 12:09:04 +0100 From: Johan Hovold To: Marcel Holtmann , Luiz Augusto von Dentz Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Johan Hedberg , Matthias Kaehlcke , Doug Anderson , Bjorn Andersson , Konrad Dybcio , linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Balakrishna Godavarthi , Nikita Travkin Subject: [PATCH v2 3/4] Bluetooth: qca: fix device-address endianness Date: Mon, 18 Mar 2024 12:08:54 +0100 Message-ID: <20240318110855.31954-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240318110855.31954-1-johan+linaro@kernel.org> References: <20240318110855.31954-1-johan+linaro@kernel.org> 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 big-endian 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 little-endian 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 big-endian 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 Tested-by: Nikita Travkin # sc7180 Signed-off-by: Johan Hovold --- 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 b40b32fa7f1c..19cfc342fc7b 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.43.2