public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Marcel Holtmann <marcel@holtmann.org>,
	Andre Heider <a.heider@gmail.com>,
	Johan Hedberg <johan.hedberg@intel.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 27/33] Bluetooth: Allow combination of BDADDR_PROPERTY and INVALID_BDADDR quirks
Date: Thu, 23 Jan 2020 20:17:02 -0500	[thread overview]
Message-ID: <20200124011708.18232-27-sashal@kernel.org> (raw)
In-Reply-To: <20200124011708.18232-1-sashal@kernel.org>

From: Marcel Holtmann <marcel@holtmann.org>

[ Upstream commit 7fdf6c6a0d0e032aac2aa4537a23af1e04a397ce ]

When utilizing BDADDR_PROPERTY and INVALID_BDADDR quirks together it
results in an unconfigured controller even if the bootloader provides
a valid address. Fix this by allowing a bootloader provided address
to mark the controller as configured.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Tested-by: Andre Heider <a.heider@gmail.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/hci_core.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 0cc9ce9172229..9e19d5a3aac87 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1444,11 +1444,20 @@ static int hci_dev_do_open(struct hci_dev *hdev)
 
 	if (hci_dev_test_flag(hdev, HCI_SETUP) ||
 	    test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
+		bool invalid_bdaddr;
+
 		hci_sock_dev_event(hdev, HCI_DEV_SETUP);
 
 		if (hdev->setup)
 			ret = hdev->setup(hdev);
 
+		/* The transport driver can set the quirk to mark the
+		 * BD_ADDR invalid before creating the HCI device or in
+		 * its setup callback.
+		 */
+		invalid_bdaddr = test_bit(HCI_QUIRK_INVALID_BDADDR,
+					  &hdev->quirks);
+
 		if (ret)
 			goto setup_failed;
 
@@ -1457,20 +1466,33 @@ static int hci_dev_do_open(struct hci_dev *hdev)
 				hci_dev_get_bd_addr_from_property(hdev);
 
 			if (bacmp(&hdev->public_addr, BDADDR_ANY) &&
-			    hdev->set_bdaddr)
+			    hdev->set_bdaddr) {
 				ret = hdev->set_bdaddr(hdev,
 						       &hdev->public_addr);
+
+				/* If setting of the BD_ADDR from the device
+				 * property succeeds, then treat the address
+				 * as valid even if the invalid BD_ADDR
+				 * quirk indicates otherwise.
+				 */
+				if (!ret)
+					invalid_bdaddr = false;
+			}
 		}
 
 setup_failed:
 		/* The transport driver can set these quirks before
 		 * creating the HCI device or in its setup callback.
 		 *
+		 * For the invalid BD_ADDR quirk it is possible that
+		 * it becomes a valid address if the bootloader does
+		 * provide it (see above).
+		 *
 		 * In case any of them is set, the controller has to
 		 * start up as unconfigured.
 		 */
 		if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) ||
-		    test_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks))
+		    invalid_bdaddr)
 			hci_dev_set_flag(hdev, HCI_UNCONFIGURED);
 
 		/* For an unconfigured controller it is required to
-- 
2.20.1


  parent reply	other threads:[~2020-01-24  1:19 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24  1:16 [PATCH AUTOSEL 5.4 01/33] extcon-intel-cht-wc: Don't reset USB data connection at probe Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 02/33] ASoC: Intel: cht_bsw_rt5645: Add quirk for boards using pmc_plt_clk_0 Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 03/33] drm/amdgpu/SRIOV: add navi12 pci id for SRIOV (v2) Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 04/33] libbpf: Fix BTF-defined map's __type macro handling of arrays Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 05/33] staging: mt7621-pci: add quirks for 'E2' revision using 'soc_device_attribute' Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 06/33] platform/x86: dell-laptop: disable kbd backlight on Inspiron 10xx Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 07/33] drm: rcar_lvds: Fix color mismatches on R-Car H2 ES2.0 and later Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 08/33] PCI: Add DMA alias quirk for Intel VCA NTB Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 09/33] media: dvbsky: add support for eyeTV Geniatech T2 lite Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 10/33] bus: ti-sysc: Handle mstandby quirk and use it for musb Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 11/33] bus: ti-sysc: Use swsup quirks also for am335x musb Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 12/33] spi: pxa2xx: Add support for Intel Comet Lake-H Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 13/33] iommu/amd: Support multiple PCI DMA aliases in device table Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 14/33] iommu/amd: Support multiple PCI DMA aliases in IRQ Remapping Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 15/33] perf/imx_ddr: Add enhanced AXI ID filter support Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 16/33] mfd: intel-lpss: Add default I2C device properties for Gemini Lake Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 17/33] mfd: intel-lpss: Add Intel Comet Lake PCH-H PCI IDs Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 18/33] ARM: config: aspeed-g5: Enable 8250_DW quirks Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 19/33] ARM: OMAP2+: SmartReflex: add omap_sr_pdata definition Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 20/33] mmc: sdhci-pci: Quirk for AMD SDHC Device 0x7906 Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 21/33] mmc: sdhci-pci: Add support for Intel JSL Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 22/33] bus: ti-sysc: Add module enable quirk for audio AESS Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 23/33] mmc: sdio: fix wl1251 vendor id Sasha Levin
2020-01-24  1:16 ` [PATCH AUTOSEL 5.4 24/33] mmc: core: fix wl1251 sdio quirks Sasha Levin
2020-01-24  1:17 ` [PATCH AUTOSEL 5.4 25/33] usb-storage: Disable UAS on JMicron SATA enclosure Sasha Levin
2020-01-24  1:17 ` [PATCH AUTOSEL 5.4 26/33] ALSA: hda/realtek - Move some alc236 pintbls to fallback table Sasha Levin
2020-01-24  1:17 ` Sasha Levin [this message]
2020-01-24  1:17 ` [PATCH AUTOSEL 5.4 28/33] Bluetooth: btbcm: Use the BDADDR_PROPERTY quirk Sasha Levin
2020-01-24  1:17 ` [PATCH AUTOSEL 5.4 29/33] bus: ti-sysc: Fix missing force mstandby quirk handling Sasha Levin
2020-01-24  1:17 ` [PATCH AUTOSEL 5.4 30/33] HID: Add quirk for Xin-Mo Dual Controller Sasha Levin
2020-01-24  1:17 ` [PATCH AUTOSEL 5.4 31/33] HID: ite: Add USB id match for Acer SW5-012 keyboard dock Sasha Levin
2020-01-24  1:17 ` [PATCH AUTOSEL 5.4 32/33] HID: Add quirk for incorrect input length on Lenovo Y720 Sasha Levin
2020-01-24  1:17 ` [PATCH AUTOSEL 5.4 33/33] drivers/hid/hid-multitouch.c: fix a possible null pointer access Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200124011708.18232-27-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=a.heider@gmail.com \
    --cc=johan.hedberg@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox