Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp446447rdd; Tue, 9 Jan 2024 08:51:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJ+el0rgPwxOGI2vb3VtzkgOwzJ1rjaJ7CmSO57IYLHGHlL30D5kNA/UJGxwPErKnlXyqT X-Received: by 2002:a05:622a:1705:b0:429:9a3d:e688 with SMTP id h5-20020a05622a170500b004299a3de688mr2815115qtk.67.1704819071991; Tue, 09 Jan 2024 08:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704819071; cv=none; d=google.com; s=arc-20160816; b=dQY0io1JEj5ShXjZXdRp2cnJKpiB8x+gmdvRmSIzjoOtVOwOTZnPutnzwwIf30pzCz /e7niFn/1jaovdUydmDg4A8xPcdfRRQt/fHoTir03IABzZi9rC86wvI4BM+JyDgEtq2/ W6ji6+oaiDTKAj7/EwC91oxoyw4kBoshcHPaWDmFSgt3DN1mqGcd0cFtkAZEmkMDBk3j MpFA2GZazT/0qki+vddu/9LlIaLW4mA98d8jIA9b6cVWL9h3kMCLKsAWZU0Kr+47rim/ 7hmptbdmh3x08a7uibe5AaDU3s4RPcRXPxXl/+9qwN/FKtqmHok7LxAZ9PODEBXzffic KtNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=uV5MEnsTPvblCSpnlyxwVtt9fk763n7/MDrWTIfZnok=; fh=LeSUAc9nEnAwLJQLqhMisddR55YrBL/oEe0zvu8XdBU=; b=rQLMFvVbHyrxQFknu2LpneJGmA8ZzYm83R/0og+4A8wapCtNLHSazvU64saUeTC9K0 +TD72iwiUHK3oevA6qNeoAFwInywDl6WmB7pIlnAHqiuVgJHtJW1Hcie3E9P1nafokMY MjlZFbHl7BOlXoRW/fW3BTtpFNShbzct05KOIkiZGd5xVqq4CRSQYTdoR7IN+PPU43ag WaWnAzLNI0ciFlCz7fFneD+VvuYyBgkskN6FzVk7mF1NgHEUS1hJivC5SHu08VnOGSJd bCPwO+dH6oTzSmy29dpxEuZH00RFsoRMQriqt/m/Dhiz6uMvz6yfr+M49wnVhMI+ZOHs NmEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=d98OVYiv; spf=pass (google.com: domain of linux-bluetooth+bounces-996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-996-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t22-20020ac85896000000b004277a3e57b1si2480027qta.554.2024.01.09.08.51.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 08:51:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=d98OVYiv; spf=pass (google.com: domain of linux-bluetooth+bounces-996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-996-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B12A11C236CB for ; Tue, 9 Jan 2024 16:51:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E28A3A8E8; Tue, 9 Jan 2024 16:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="d98OVYiv" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1BE439FFC for ; Tue, 9 Jan 2024 16:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-3608cfa5ce6so12158805ab.0 for ; Tue, 09 Jan 2024 08:51:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1704819060; x=1705423860; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=uV5MEnsTPvblCSpnlyxwVtt9fk763n7/MDrWTIfZnok=; b=d98OVYivllbnDuKnYQ2IRawOBiPUDUUCI8BkXAlC0/zoODQ46L+sHVPO4eUZo4wpAK HRuKsEvnSPerUfpNfnToo47LtHj9b2Ad6KtimED8MdzJ49eYnvl6rTNR2vyOARaKf9D9 6vp+kWqvUUj3PiFJ7/SMYPKrqVVE/a6KuVkAg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704819060; x=1705423860; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uV5MEnsTPvblCSpnlyxwVtt9fk763n7/MDrWTIfZnok=; b=j97KOHsO1vjJHoO/ESsaVA3HkmqqZEKxC0avx0lp/bewKzpuRgUC8u37Wzk8iGAthH rOSVx2djwTfdCIV/ItN4l8PAsKbHYsQDdtue6kPwHpG5MLpZUYqlhemRreTB+UAKzSky LhUlikOnQZAL6utbC3obphnk9iFVvp2qExKdPMw+b6bVzKpUIC2ogFB7PnEYWeUPhEuo RbezR66J/Dzoonmo6Lz0MDBysNfiA4i1E7dkKj6cgzXltoJIxW4x3bkL1oSYMlFfOISA 9x0lc13e1P+T8TfJK5oiM4Km1yV+wOj01aLl1D1xGb1FmXPL4fSrFw3JQjJHoO3Kc6T0 yeaQ== X-Gm-Message-State: AOJu0Yxn/5nAxvHS08l1EPcPjf3OSJ4Q+K59uJ8p5oUmNNBpKsOkb3B9 gF3DJpl6oNakLvMQDEVWqlS7OuaSKcWz X-Received: by 2002:a92:ca09:0:b0:360:7c05:e479 with SMTP id j9-20020a92ca09000000b003607c05e479mr9251232ils.47.1704819059849; Tue, 09 Jan 2024 08:50:59 -0800 (PST) Received: from localhost (110.41.72.34.bc.googleusercontent.com. [34.72.41.110]) by smtp.gmail.com with UTF8SMTPSA id t12-20020a92c90c000000b003607ff64574sm689592ilp.64.2024.01.09.08.50.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jan 2024 08:50:59 -0800 (PST) Date: Tue, 9 Jan 2024 16:50:59 +0000 From: Matthias Kaehlcke To: Johan Hovold Cc: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , Bjorn Andersson , Konrad Dybcio , linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Balakrishna Godavarthi , Doug Anderson , Stephen Boyd Subject: Re: [PATCH] Bluetooth: qca: fix device-address endianness Message-ID: References: <20231227180306.6319-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-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231227180306.6319-1-johan+linaro@kernel.org> Hi Johan, On Wed, Dec 27, 2023 at 07:03:06PM +0100, Johan Hovold wrote: > 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. We should not break existing devices. Their byte order for 'local-bd-address' may not adhere to the 'spec', however in practice it is the correct format for existing kernels. I suggest adding a quirk like 'local-bd-address-msb-quirk' or 'qcom,local-bd-address-msb-quirk' to make sure existing devices keep working properly. Thanks Matthias > > 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 >