Bluetooth: fix bdaddr quirks
Subsystems (4)
cover Bluetooth: fix bdaddr quirks
These patches fixes a couple of issues with the two bdaddr quirks:
The first one allows HCI_QUIRK_INVALID_BDADDR to be used with HCI_QUIRK_NON_PERSISTENT_SETUP.
The second patch restores the original semantics of the HCI_QUIRK_USE_BDADDR_PROPERTY so that the controller is marked as unconfigured when no device address is specified in the devicetree (as the quirk is documented to work).
This specifically makes sure that Qualcomm HCI controllers such as wcn6855 found on the Lenovo X13s are marked as unconfigured until user space has provided a valid address.
Long term, the HCI_QUIRK_USE_BDADDR_PROPERTY should probably be dropped in favour of HCI_QUIRK_INVALID_BDADDR and always checking the devicetree property.
Johan
Johan Hovold (2):
Bluetooth: fix invalid-bdaddr quirk for non-persistent setup
Bluetooth: fix use-bdaddr-property quirk
net/bluetooth/hci_sync.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-)
Signature · 1 line
2.39.2
PATCH 2/2 Bluetooth: fix use-bdaddr-property quirk
Devices that lack persistent storage for the device address can indicate this by setting the HCI_QUIRK_INVALID_BDADDR which causes the controller to be marked as unconfigured until user space has set a valid address.
The related HCI_QUIRK_USE_BDADDR_PROPERTY was later added to similarly indicate that the device lacks a valid address but that one may be specified in the devicetree.
As is clear from commit 7a0e5b15ca45 ("Bluetooth: Add quirk for reading BD_ADDR from fwnode property") that added and documented this quirk and commits like de79a9df1692 ("Bluetooth: btqcomsmd: use HCI_QUIRK_USE_BDADDR_PROPERTY"), the device address of controllers with this flag should be treated as invalid until user space has had a chance to configure the controller in case the devicetree property is missing.
As it does not make sense to allow controllers with invalid addresses, restore the original semantics, which also makes sure that the implementation is consistent (e.g. get_missing_options() indicates that the address must be set) and matches the documentation (including comments in the code, such as, "In case any of them is set, the controller has to start up as unconfigured.").
--- net/bluetooth/hci_sync.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
net/bluetooth/hci_sync.c +3 -5
@@ -4570,16 +4570,14 @@ static int hci_dev_setup_sync(struct hci_dev *hdev)* BD_ADDR invalid before creating the HCI device or in * its setup callback. */ - invalid_bdaddr =test_bit (HCI_QUIRK_INVALID_BDADDR , &hdev->quirks); - + invalid_bdaddr =test_bit (HCI_QUIRK_INVALID_BDADDR , &hdev->quirks) || +test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks);if (!ret) {if (test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks) && !bacmp (&hdev->public_addr,BDADDR_ANY ))hci_dev_get_bd_addr_from_property (hdev); -if ((invalid_bdaddr || -test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks)) && -bacmp (&hdev->public_addr,BDADDR_ANY ) && +if (invalid_bdaddr &&bacmp (&hdev->public_addr,BDADDR_ANY ) && hdev->set_bdaddr) { ret = hdev->set_bdaddr (hdev, &hdev->public_addr);if (!ret)
Signature · 1 line
2.39.2
PATCH 1/2 Bluetooth: fix invalid-bdaddr quirk for non-persistent setup
In reply to Johan HovoldDevices that lack persistent storage for the device address can indicate this by setting the HCI_QUIRK_INVALID_BDADDR which causes the controller to be marked as unconfigured until user space has set a valid address.
Once configured, the device address must be set on every setup for controllers with HCI_QUIRK_NON_PERSISTENT_SETUP to avoid marking the controller as unconfigured and requiring the address to be set again.
--- net/bluetooth/hci_sync.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
net/bluetooth/hci_sync.c +11 -17
@@ -4573,23 +4573,17 @@ static int hci_dev_setup_sync(struct hci_dev *hdev) invalid_bdaddr =test_bit (HCI_QUIRK_INVALID_BDADDR , &hdev->quirks);if (!ret) { -if (test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks)) { -if (!bacmp (&hdev->public_addr,BDADDR_ANY )) -hci_dev_get_bd_addr_from_property (hdev); - -if (bacmp (&hdev->public_addr,BDADDR_ANY ) && - 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; - } +if (test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks) && + !bacmp (&hdev->public_addr,BDADDR_ANY )) +hci_dev_get_bd_addr_from_property (hdev); + +if ((invalid_bdaddr || +test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks)) && +bacmp (&hdev->public_addr,BDADDR_ANY ) && + hdev->set_bdaddr) { + ret = hdev->set_bdaddr (hdev, &hdev->public_addr); +if (!ret) + invalid_bdaddr = false; } }
Signature · 1 line
2.39.2
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=742739
---Test result---
Test Summary:
CheckPatch PASS 1.43 seconds GitLint PASS 0.70 seconds SubjectPrefix PASS 0.25 seconds BuildKernel PASS 33.28 seconds CheckAllWarning PASS 36.79 seconds CheckSparse PASS 41.35 seconds CheckSmatch PASS 112.04 seconds BuildKernel32 PASS 31.97 seconds TestRunnerSetup PASS 455.91 seconds TestRunner_l2cap-tester PASS 17.25 seconds TestRunner_iso-tester PASS 21.82 seconds TestRunner_bnep-tester PASS 5.68 seconds TestRunner_mgmt-tester PASS 118.17 seconds TestRunner_rfcomm-tester PASS 9.22 seconds TestRunner_sco-tester PASS 8.57 seconds TestRunner_ioctl-tester PASS 10.00 seconds TestRunner_mesh-tester PASS 7.28 seconds TestRunner_smp-tester PASS 8.34 seconds TestRunner_userchan-tester PASS 6.08 seconds IncrementalBuild PASS 36.91 seconds
---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz
maintainerRe: [PATCH 1/2] Bluetooth: fix invalid-bdaddr quirk for non-persistent setup
In reply to Johan HovoldHi Johan,
Quoted 41 lines · Johan Hovold
Devices that lack persistent storage for the device address can indicate this by setting the
HCI_QUIRK_INVALID_BDADDRwhich causes the controller to be marked as unconfigured until user space has set a valid address.Once configured, the device address must be set on every setup for controllers with
HCI_QUIRK_NON_PERSISTENT_SETUPto avoid marking the controller as unconfigured and requiring the address to be set again.Fixes 740011cfe948 ("Bluetooth: Add new quirk for non-persistent setup settings")Signed-off-by Johan Hovold <[email protected]>--- net/bluetooth/hci_sync.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)net/bluetooth/hci_sync.c +1
-17@@ -4573,23 +4573,17 @@ static int hci_dev_setup_sync(struct hci_dev *hdev) invalid_bdaddr =test_bit (HCI_QUIRK_INVALID_BDADDR , &hdev->quirks);if (!ret) { -if (test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks)) { -if (!bacmp (&hdev->public_addr,BDADDR_ANY )) -hci_dev_get_bd_addr_from_property (hdev); - -if (bacmp (&hdev->public_addr,BDADDR_ANY ) && - 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; - } + if (test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks) &&
net/bluetooth/hci_sync.c static int hci_dev_setup_sync(struct hci_dev *hdev) · line 4586
Quoted 10 lines
net/bluetooth/hci_sync.c +10
-0+ !bacmp(&hdev->public_addr, BDADDR_ANY)) +hci_dev_get_bd_addr_from_property (hdev); + +if ((invalid_bdaddr || +test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks)) && +bacmp (&hdev->public_addr,BDADDR_ANY ) && + hdev->set_bdaddr) { + ret = hdev->set_bdaddr (hdev, &hdev->public_addr); +if (!ret) + invalid_bdaddr = false;
I'd keep the original comments since it appears you haven't changed its logic with respect to invalid_bdaddr.
Quoted 6 lines
net/bluetooth/hci_sync.c +0
-1} } --2.39.2
Signature · 1 line
Luiz Augusto von Dentz
Re: [PATCH 1/2] Bluetooth: fix invalid-bdaddr quirk for non-persistent setup
Quoted 49 lines · Luiz Augusto von Dentz
Hi Johan,
Quoted 46 lines · Johan Hovold
Devices that lack persistent storage for the device address can indicate this by setting the
HCI_QUIRK_INVALID_BDADDRwhich causes the controller to be marked as unconfigured until user space has set a valid address.Once configured, the device address must be set on every setup for controllers with
HCI_QUIRK_NON_PERSISTENT_SETUPto avoid marking the controller as unconfigured and requiring the address to be set again.Fixes 740011cfe948 ("Bluetooth: Add new quirk for non-persistent setup settings")Signed-off-by Johan Hovold <[email protected]>--- net/bluetooth/hci_sync.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)net/bluetooth/hci_sync.c +6
-17@@ -4573,23 +4573,17 @@ static int hci_dev_setup_sync(struct hci_dev *hdev) invalid_bdaddr =test_bit (HCI_QUIRK_INVALID_BDADDR , &hdev->quirks);if (!ret) { -if (test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks)) { -if (!bacmp (&hdev->public_addr,BDADDR_ANY )) -hci_dev_get_bd_addr_from_property (hdev); - -if (bacmp (&hdev->public_addr,BDADDR_ANY ) && - 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; - } +if (test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks) && + !bacmp (&hdev->public_addr,BDADDR_ANY )) +hci_dev_get_bd_addr_from_property (hdev); + + if ((invalid_bdaddr || + test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks)) &&
Quoted 8 lines
net/bluetooth/hci_sync.c static int hci_dev_setup_sync(struct hci_dev *hdev) · line 4586
Quoted 5 lines
net/bluetooth/hci_sync.c +5
-0+ bacmp(&hdev->public_addr, BDADDR_ANY) && + hdev->set_bdaddr) { + ret = hdev->set_bdaddr (hdev, &hdev->public_addr); +if (!ret) + invalid_bdaddr = false;I'd keep the original comments since it appears you haven't changed its logic with respect to
invalid_bdaddr.
The comment no longer applies as set_bdaddr can now be called also when there is no "device property" holding the address (e.g. when one has been set using btmgmt and HCI_QUIRK_NON_PERSISTENT_SETUP is set).
And obviously we shouldn't mark the controller as unconfigured after we've successfully set an address.
Johan
Quoted 18 lines · Johan Hovold
These patches fixes a couple of issues with the two bdaddr quirks:
The first one allows
HCI_QUIRK_INVALID_BDADDRto be used withHCI_QUIRK_NON_PERSISTENT_SETUP.The second patch restores the original semantics of the
HCI_QUIRK_USE_BDADDR_PROPERTYso that the controller is marked as unconfigured when no device address is specified in the devicetree (as the quirk is documented to work).This specifically makes sure that Qualcomm HCI controllers such as wcn6855 found on the Lenovo X13s are marked as unconfigured until user space has provided a valid address.
Long term, the
HCI_QUIRK_USE_BDADDR_PROPERTYshould probably be dropped in favour ofHCI_QUIRK_INVALID_BDADDRand always checking the devicetree property.
Quoted 6 lines
Johan Hovold (2):
Bluetooth: fix invalid-bdaddr quirk for non-persistent setup
Bluetooth: fix use-bdaddr-property quirknet/bluetooth/hci_sync.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-)
Any further comments to this series, or can this one be merged for 6.5 now?
Johan
Luiz Augusto von Dentz
maintainerHi Johan,
Quoted 24 lines · Johan Hovold
Quoted 22 lines · Johan Hovold
These patches fixes a couple of issues with the two bdaddr quirks:
The first one allows
HCI_QUIRK_INVALID_BDADDRto be used withHCI_QUIRK_NON_PERSISTENT_SETUP.The second patch restores the original semantics of the
HCI_QUIRK_USE_BDADDR_PROPERTYso that the controller is marked as unconfigured when no device address is specified in the devicetree (as the quirk is documented to work).This specifically makes sure that Qualcomm HCI controllers such as wcn6855 found on the Lenovo X13s are marked as unconfigured until user space has provided a valid address.
Long term, the
HCI_QUIRK_USE_BDADDR_PROPERTYshould probably be dropped in favour ofHCI_QUIRK_INVALID_BDADDRand always checking the devicetree property.Johan Hovold (2):
Bluetooth: fix invalid-bdaddr quirk for non-persistent setup
Bluetooth: fix use-bdaddr-property quirk
Quoted 5 lines
Quoted 2 lines
net/bluetooth/hci_sync.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-)Any further comments to this series, or can this one be merged for 6.5 now?
Looks like this was removed from Patchwork since it has passed 30 days without updates, could you please resend it so CI can pick it up and test it again.
Quoted 1 line
Johan
Signature · 1 line
Luiz Augusto von Dentz
Quoted 11 lines · Luiz Augusto von Dentz
Quoted 6 lines · Johan Hovold
Quoted 1 line · Johan Hovold
These patches fixes a couple of issues with the two bdaddr quirks:
Any further comments to this series, or can this one be merged for 6.5 now?
Looks like this was removed from Patchwork since it has passed 30 days without updates, could you please resend it so CI can pick it up and test it again.
Both series resent:
https://lore.kernel.org/lkml/[email protected]/ https://lore.kernel.org/lkml/[email protected]/
Getting both of these, or at least the first one, into 6.4 would of course be even better.
Thanks.
Johan