Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1839395lqa; Tue, 30 Apr 2024 00:07:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWrwbAulbgxHMp4s//5kJF0RBEC09oHCRKndndGbSUxW0cksJXlTtafL9pdrMZKA+3IkgvR2gyWj+bBxc54a1zpawQc4rpMXSQbXlWO4A== X-Google-Smtp-Source: AGHT+IGvleQPvUogg29aWWInKaWgHh5qoFn0rQ4r1YguZ8xQ9kAnqOgbuHe3xZ8H7ZxSQ682fXuo X-Received: by 2002:ae9:ee17:0:b0:790:ad27:41a8 with SMTP id i23-20020ae9ee17000000b00790ad2741a8mr10493843qkg.8.1714460869073; Tue, 30 Apr 2024 00:07:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714460869; cv=pass; d=google.com; s=arc-20160816; b=Q/c4gJ0D1AMXZyUkEndql2lmrYJpQI9z9Pl9gWQUX03oO/gHqt664WnPgAgtR12NbU ZFeFaEvdCjE+hsFCU/lamKe3gHI4V97Mr+H+bCcelmD8sMqb247vAjXxGkpX7SJw8KdZ NJ1X0elSjWfQ8cBYOPV6D2gsBmm8Y2kpOh5JUss4y3hs9bguZqdAQD/NacACHCO8uWJw 75hqIsVGIpf6gIDCQneLXujjiEocUrr+9FnPj2Q5/EHfO49MKr//Qaef1eVeATdBG/sA NpdoYxKoLrUJ8F5AxcEC5xQ1EysqGYXEJzSfh1sy7DQRRSM7rwIJwM5GN7JUxDvKWqId 7YtA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kowVP8FiIttPqnPuVIWG+ziaAbTwlWsfojWWYQ4XC2o=; fh=KtpYlTaIs30jFEzCjAPL2jAFTj64bjez/lrR6HW/2JU=; b=I8I+VNQapXX6mXZeUgXEvDh/FiHKpFHOPyl/lyERz03qrUZjrXjRwcCSbqDrfV8ZW2 YjcqzZpbwOvbihf3cSY8YnkAXSgTMrgqzoKE8wSETA+WTcQopORM7ClmMzGQMPzGdS5d 0vKdaXD94BSPqWLJjZO7RtNNCCuXWMqLZq8AEd/3P4n0AIMoSZNKB6lI32iFKadjVZpI hdlF/GHzfl3BaHKK7ekRvn6PkV0fuOd03ruwmfSi1qEJCfsyFSOmOd+wF2vC/VxHxoIt x3E4rV2lBIj+kvVSx/q3QMdnFQ4Ap3ixt3HgBzRWtiGIFkBZMy1Rlv1NFaoEvIQnGLeF 5HGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xp02gZOu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-bluetooth+bounces-4175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4175-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 j4-20020a05620a000400b00790fc6ebce0si2756780qki.148.2024.04.30.00.07.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 00:07:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4175-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=@kernel.org header.s=k20201202 header.b=Xp02gZOu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-bluetooth+bounces-4175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4175-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7414A1C21D71 for ; Tue, 30 Apr 2024 07:07:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0306B335BC; Tue, 30 Apr 2024 07:07:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Xp02gZOu" 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 5F5501BF20; Tue, 30 Apr 2024 07:07:40 +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=1714460860; cv=none; b=WuxTwYcEeSZ9migh7l1zcaQnaUvnEPv+kqeIRN+LhTVxzSU8f71WUeAvtRS2oDryRB38z+ccHLd/Mdgm57rhjv19z/GaCrdKhqytw0PTZSMrF5tqGv1y9GswIMuapLhR+LWbqKQJNgOxxGJvSzSxhdvSwHvgXGM51sJewB6mDHo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714460860; c=relaxed/simple; bh=TxxoVyNCTc8zKzy9eUibWwwSsZ9EVbgR21o1ZrGuGEc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WTeSWrXjzYxryTbiEpBBema+uTh9jmW6uLPXf3pj7cNWzYKJShOPMR46NjOyj8x7c/HA7qmtGgFlX+++f1VrqmS2vk2HjUoQ3oH4sj7uImWnsatrhyIPVVViX+mEb4mgpj5Up3XAKh3hnYQ+IOb7HG/Y/BZlq22EACVml7Yy+HM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Xp02gZOu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC6B9C2BBFC; Tue, 30 Apr 2024 07:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714460859; bh=TxxoVyNCTc8zKzy9eUibWwwSsZ9EVbgR21o1ZrGuGEc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Xp02gZOuaCjcoryLVoJCy0y7IiN90uQXlnQ1kWz3gvaxiT03THk2OtyM1+FYr4SbQ Yfzat1QYHu7zWQn8P/dN50FB69HOlQ4MzhEqgc2cuievryMl9tZ9NFwoPkL6xja3Q7 gsQ6m+CIndtJLJ/cP4L3RUh7kad5yEFTdLABCY/fqiW4UJ4bMEqvOjtF6QiR7eisuM JYBUyJzHcnwt9e8qKvfoX5Oadz3bpzi//Mm82cNKQBfHeu6NMSFxcptB3TPKKu6L60 aEkGEj+tSC8VdVmSRjmviTZDy2ebVr5f7aSb+k6btejZ+/F6e+2T3Lcl8bFEIXlyyW T5XY6CzBMGg4g== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1s1haV-000000001Uw-2oBY; Tue, 30 Apr 2024 09:07:40 +0200 Date: Tue, 30 Apr 2024 09:07:39 +0200 From: Johan Hovold To: Luiz Augusto von Dentz Cc: Janaki Ramaiah Thota , Doug Anderson , Johan Hovold , Marcel Holtmann , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, quic_mohamull@quicinc.com, quic_hbandi@quicinc.com, quic_anubhavg@quicinc.com Subject: Re: [PATCH] Bluetooth: qca: generalise device address check Message-ID: References: <20240426155801.25277-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 Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Apr 29, 2024 at 01:31:53PM -0400, Luiz Augusto von Dentz wrote: > On Mon, Apr 29, 2024 at 1:12 PM Luiz Augusto von Dentz > wrote: > > On Mon, Apr 29, 2024 at 10:02 AM Johan Hovold wrote: > > > On Mon, Apr 29, 2024 at 03:34:32PM +0530, Janaki Ramaiah Thota wrote: > > > > Having a default BDA list from NVM BDA tag value will prevent developers > > > > from using the device if there is no user space app(In Fluoride) to set > > > > the BDA. Therefore, we are requesting to use default address check patch, > > > > so that developer can change the NVM BDA to make use of the device. > > > > > > But a developer on such an old platform that can patch and replace the > > > NVM configuration file should also be able to just disable the check in > > > the driver right (e.g. by commenting out the call to > > > qca_check_bdaddr())? > > > > > > > List Of default Addresses: > > > > --------------------------------------------------------- > > > > | BDA | Chipset | > > > > --------------------------------------------------------- > > > > | 39 80 10 00 00 20 | WCN3988 with ROM Version 0x0200 | > > > > --------------------------------------------------------- > > > > | 39 80 12 74 08 00 | WCN3988 with ROM Version 0x0201 | > > > > --------------------------------------------------------- > > > > | 39 90 21 64 07 00 | WCN3990 | > > > > --------------------------------------------------------- > > > > | 39 98 00 00 5A AD | WCN3991 | > > > > --------------------------------------------------------- > > > > | 00 00 00 00 5A AD | QCA DEFAULT | > > > > --------------------------------------------------------- > > > > > > What about WCN6750 and 64:90:00:00:5a:ad? > > > > > > And then there's currently also: > > > > > > > > bluetooth hci0: bd_addr = 61:47:aa:31:22:14 (qca/nvm_00130300.bin) > > > > > bluetooth hci0: bd_addr = 61:47:aa:32:44:07 (qca/nvm_00130302.bin) > > > > > > Which controllers use these configurations? > > > > These are not unique addresses though, we can't just have addresses by > > chipset address mapping logic as that would cause address clashes over > > the air, e.g. if there are other devices with the same chipset in the > > vicinity. > > I see where this is going now, the firmware actually contain these > duplicated addresses which then are checked and cause > HCI_QUIRK_USE_BDADDR_PROPERTY then the tries > hci_dev_get_bd_addr_from_property which loads the local-bd-address > property from the parente device (SOC?), btw that could also have an > invalid/duplicated address. Right, the expectation is that vendors don't abuse this and leave the address in the devicetree as all-zero unless the boot firmware has access to a unique address. HCI_QUIRK_USE_BDADDR_PROPERTY effectively implies HCI_QUIRK_INVALID_BDADDR, that is, both quirks marks the controller address as invalid. The only difference is that the former also goes out and checks if there's an address in the devicetree that can be used instead. The 'local-bd-address' property is used on boards where the boot firmware has access to some storage for the address and updates the devicetree with the board-specific address before passing the DT to the kernel. As I've mentioned before, we should probably just drop HCI_QUIRK_USE_BDADDR_PROPERTY eventually and always look for an address in the devicetree when HCI_QUIRK_INVALID_BDADDR is set instead. We could take that one step further and always let the devicetree override the controller address as Doug suggested, but I'm not sure that's what we want to do generally. Either way, these are later questions. > Anyway the fact that firmware loading itself is programming a > potentially duplicated address already seems wrong enough to me, > either it shall leave it as 00... or set a valid address otherwise we > always risk missing yet another duplicate address being introduced and > then used over the air causing all sorts of problems for users. > > So to be clear, QCA firmware shall never attempt to flash anything > other than 00:00:00:00:00:00 if you don't have a valid and unique > identity address, so we can get rid of this table altogether. Nothing is being flashed, but when the controller has not been provisioned with an address, the address in the NVM configuration file is used. And we need to handle this in some way, as the configuration files are already out there (e.g. in linux-firmware) and are honoured by the QCA firmware. My patch reads out the default address from the configuration file before downloading it during setup() so that no matter what address is set this way, it will be treated as non-unique and invalid. This way we don't need to maintain any table in the kernel and we don't risk any regressions if the address is ever changed in a later firmware update. The only downside is that developers on old platforms that don't have any user space tools to set a valid address (e.g. btmgmt) cannot set an address by patching the firmware file. But I don't think we need to care about that. I assume that in most cases those developers all just use the default address, with the risk of collisions that that implies. We have a standard APIs for configuring the address, just use that. > ps: If the intention is to have these addresses for testing then these > firmwares files shall probably be kept private, since as explained > above the use of duplicated addresses will cause problems to users who > have no idea they have to be changed. Johan