Bluetooth: qca: fix device-address endianness
Subsystems (10)
v3 cover Bluetooth: qca: fix device-address endianness
The Qualcomm Bluetooth driver is configuring the device address in reverse order for none-ROME devices, which breaks user space tools like btmgmt and the 'local-bd-address' devicetree property.
As these Qualcomm controllers lack persistent storage for the device address, boot firmware can use the 'local-bd-address' devicetree property to provide a valid address. The property should specify the address in little endian order but instead some boot firmware has been reversing the address to match the buggy Qualcomm driver.
This specifically affects some Chromebook devices for which we now need to maintain compatibility with the current boot firmware. As ChromeOS updates the kernel and devicetree in lockstep, this can be done by adding a new 'qcom,local-bd-address-broken' property that can be used to determine if the firmware passes the address in the wrong byte order. [1][2]
Note that this series depends on the following revert:
https://lore.kernel.org/lkml/[email protected]/
Also note that the final patch is expected to be merged through the Qualcomm SoC tree once the first four patches have been picked up by the Bluetooth maintainers.
Johan
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/CAD=FV=WCzrh926mkiyBnKRG_+KGuOkGN6v0DgPiXhQCD3PSQ9w@mail.gmail.com/
Changes in v3
- add a 'qcom,local-bd-address-broken' property instead of deprecating the current WCN3991 binding
- mark the bluetooth address on SC7180 Trogdor Chromebooks as broken
Changes in v2
- add quirk to handle deprecated devicetree compatibles that expect broken address properties
- deprecate 'qcom,wcn3991-bt' and mark it as broken
Johan Hovold (5):
dt-bindings: bluetooth: add 'qcom,local-bd-address-broken'
Bluetooth: add quirk for broken address properties
Bluetooth: qca: fix device-address endianness
Bluetooth: qca: add workaround for broken address properties
arm64: dts: qcom: sc7180-trogdor: mark bluetooth address as broken
.../bindings/net/bluetooth/qualcomm-bluetooth.yaml | 3 +++ arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi | 2 ++ drivers/bluetooth/btqca.c | 8 ++++++-- drivers/bluetooth/hci_qca.c | 10 ++++++++++ include/net/bluetooth/hci.h | 9 +++++++++ net/bluetooth/hci_sync.c | 5 ++++- 6 files changed, 34 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.2
PATCH v3 1/5 dt-bindings: bluetooth: add 'qcom,local-bd-address-broken'
Several Qualcomm Bluetooth controllers lack persistent storage for the device address and instead one can be provided by the boot firmware using the 'local-bd-address' devicetree property.
The Bluetooth bindings clearly states that the address should be specified in little-endian order, but due to a long-standing bug in the Qualcomm driver which reversed the address some boot firmware has been providing the address in big-endian order instead.
The only device out there that should be affected by this is the WCN3991 used in some Chromebooks.
Add a 'qcom,local-bd-address-broken' property which can be set on these platforms to indicate that the boot firmware is using the wrong byte order.
Note that ChromeOS always updates the kernel and devicetree in lockstep so that there is no need to handle backwards compatibility with older devicetrees.
--- .../devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml +3 -0
@@ -94,6 +94,9 @@ properties: local-bd-address: true + qcom,local-bd-address-broken: true + description: > + boot firmware is incorrectly passing the address in big-endian order required: - compatible
Signature · 1 line
2.43.2
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: patch failed: drivers/bluetooth/hci_qca.c:1904
error: drivers/bluetooth/hci_qca.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth
Re: [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken'
In reply to Johan HovoldHi,
Quoted 31 lines · Johan Hovold
Several Qualcomm Bluetooth controllers lack persistent storage for the device address and instead one can be provided by the boot firmware using the 'local-bd-address' devicetree property.
The Bluetooth bindings clearly states that the address should be specified in little-endian order, but due to a long-standing bug in the Qualcomm driver which reversed the address some boot firmware has been providing the address in big-endian order instead.
The only device out there that should be affected by this is the WCN3991 used in some Chromebooks.
Add a 'qcom,local-bd-address-broken' property which can be set on these platforms to indicate that the boot firmware is using the wrong byte order.
Note that ChromeOS always updates the kernel and devicetree in lockstep so that there is no need to handle backwards compatibility with older devicetrees.
Signed-off-by Johan Hovold <[email protected]>--- .../devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml | 3 +++ 1 file changed, 3 insertions(+)Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml +0
-0
Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml properties: · line 99
Quoted 6 lines
Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml +3
-0@@ -94,6 +94,9 @@ properties: local-bd-address: true + qcom,local-bd-address-broken: true + description: > + boot firmware is incorrectly passing the address in big-endian order
Personally, I feel like "qcom,local-bd-address-backwards" or "qcom,local-bd-address-swapped" would be more documenting but I don't feel super strongly about it. I guess "broken" makes it more obvious that this is not just a normal variant that someone should use. If DT binding folks are happy, I'm happy enough with this solution.
Re: [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken'
Quoted 10 lines · Doug Anderson
Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml properties: · line 99
Quoted 3 lines · Johan Hovold
Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml +3
-0+ qcom,local-bd-address-broken: true + description: > + boot firmware is incorrectly passing the address in big-endian orderPersonally, I feel like "qcom,local-bd-address-backwards" or "qcom,local-bd-address-swapped" would be more documenting but I don't feel super strongly about it. I guess "broken" makes it more obvious that this is not just a normal variant that someone should use.
Yeah, that is precisely why I chose that name, to avoid having people think this is something they can just pick and choose for their driver.
As is repeatedly made clear, this needs to be obvious from the name, as apparently not many people bother to look up the documentation.
Quoted 3 lines
If DT binding folks are happy, I'm happy enough with this solution.
Reviewed-by Douglas Anderson <[email protected]>
Thanks for reviewing.
Johan
Rob Herring
maintainerRe: [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken'
In reply to Johan HovoldQuoted 16 lines · Johan Hovold
Several Qualcomm Bluetooth controllers lack persistent storage for the device address and instead one can be provided by the boot firmware using the 'local-bd-address' devicetree property.
The Bluetooth bindings clearly states that the address should be specified in little-endian order, but due to a long-standing bug in the Qualcomm driver which reversed the address some boot firmware has been providing the address in big-endian order instead.
The only device out there that should be affected by this is the WCN3991 used in some Chromebooks.
Add a 'qcom,local-bd-address-broken' property which can be set on these platforms to indicate that the boot firmware is using the wrong byte order.
Quoted 9 lines
Note that ChromeOS always updates the kernel and devicetree in lockstep so that there is no need to handle backwards compatibility with older devicetrees.
Signed-off-by Johan Hovold <[email protected]>--- .../devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml | 3 +++ 1 file changed, 3 insertions(+)
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:./Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml:98:16: [error] syntax error: mapping values are not allowed here (syntax)
dtschema/dtc warnings/errors:
make[2]: *** Deleting file 'Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.example.dts' Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml:98:16: mapping values are not allowed in this context make[2]: *** [Documentation/devicetree/bindings/Makefile:26: Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.example.dts] Error 1 make[2]: *** Waiting for unfinished jobs.... ./Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml:98:16: mapping values are not allowed in this context /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml: ignoring, error parsing file make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1428: dt_binding_check] Error 2
make: *** [Makefile:240: __sub-make] Error 2
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
PATCH v3 2/5 Bluetooth: add quirk for broken address properties
In reply to Johan HovoldSome Bluetooth controllers lack persistent storage for the device address and instead one can be provided by the boot firmware using the 'local-bd-address' devicetree property.
The Bluetooth devicetree bindings clearly states that the address should be specified in little-endian order, but due to a long-standing bug in the Qualcomm driver which reversed the address some boot firmware has been providing the address in big-endian order instead.
Add a new quirk that can be set on platforms with broken firmware and use it to reverse the address when parsing the property so that the underlying driver bug can be fixed.
--- include/net/bluetooth/hci.h | 9 +++++++++ net/bluetooth/hci_sync.c | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-)
include/net/bluetooth/hci.h +9 -0
@@ -176,6 +176,15 @@ enum {*/ HCI_QUIRK_USE_BDADDR_PROPERTY , +/* When this quirk is set, the Bluetooth Device Address provided by +* the 'local-bd-address' fwnode property is incorrectly specified in +* big-endian order. +* +* This quirk can be set before hci_register_dev is called or +* during the hdev->setup vendor callback. +*/ + HCI_QUIRK_BDADDR_PROPERTY_BROKEN, +/* When this quirk is set, the duplicate filtering during * scanning is based on Bluetooth devices addresses. To allow * RSSI based updates, restart scanning if needed.
net/bluetooth/hci_sync.c +4 -1
@@ -3215,7 +3215,10 @@ static void hci_dev_get_bd_addr_from_property(struct hci_dev *hdev)if (ret <0 || !bacmp (&ba,BDADDR_ANY ))return ; -bacpy (&hdev->public_addr, &ba); +if (test_bit (HCI_QUIRK_BDADDR_PROPERTY_BROKEN , &hdev->quirks)) +baswap (&hdev->public_addr, &ba); +else +bacpy (&hdev->public_addr, &ba); }struct hci_init_stage {
Signature · 1 line
2.43.2
Re: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
Hi,
Quoted 28 lines · Johan Hovold
Some Bluetooth controllers lack persistent storage for the device address and instead one can be provided by the boot firmware using the 'local-bd-address' devicetree property.
The Bluetooth devicetree bindings clearly states that the address should be specified in little-endian order, but due to a long-standing bug in the Qualcomm driver which reversed the address some boot firmware has been providing the address in big-endian order instead.
Add a new quirk that can be set on platforms with broken firmware and use it to reverse the address when parsing the property so that the underlying driver bug can be fixed.
Fixes 5c0a1001c8be ("Bluetooth: hci_qca: Add helper to set device address")Cc [email protected] # 5.1Signed-off-by Johan Hovold <[email protected]>--- include/net/bluetooth/hci.h | 9 +++++++++ net/bluetooth/hci_sync.c | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-)include/net/bluetooth/hci.h +0
-0@@ -176,6 +176,15 @@ enum {*/
include/net/bluetooth/hci.h enum { · line 186
Quoted 10 lines
include/net/bluetooth/hci.h +8
-0HCI_QUIRK_USE_BDADDR_PROPERTY , +/* When this quirk is set, the Bluetooth Device Address provided by +* the 'local-bd-address' fwnode property is incorrectly specified in +* big-endian order. +* +* This quirk can be set before hci_register_dev is called or +* during the hdev->setup vendor callback. +*/ + HCI_QUIRK_BDADDR_PROPERTY_BROKEN,
Like with the binding, I feel like "HCI_QUIRK_BDADDR_PROPERTY_BACKWARDS" or "HCI_QUIRK_BDADDR_PROPERTY_SWAPPED" would be more documenting but I don't feel strongly.
Re: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
Quoted 33 lines · Doug Anderson
Hi,
Quoted 30 lines · Johan Hovold
Some Bluetooth controllers lack persistent storage for the device address and instead one can be provided by the boot firmware using the 'local-bd-address' devicetree property.
The Bluetooth devicetree bindings clearly states that the address should be specified in little-endian order, but due to a long-standing bug in the Qualcomm driver which reversed the address some boot firmware has been providing the address in big-endian order instead.
Add a new quirk that can be set on platforms with broken firmware and use it to reverse the address when parsing the property so that the underlying driver bug can be fixed.
Fixes 5c0a1001c8be ("Bluetooth: hci_qca: Add helper to set device address")Cc [email protected] # 5.1Signed-off-by Johan Hovold <[email protected]>--- include/net/bluetooth/hci.h | 9 +++++++++ net/bluetooth/hci_sync.c | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-)include/net/bluetooth/hci.h +0
-0@@ -176,6 +176,15 @@ enum {*/ HCI_QUIRK_USE_BDADDR_PROPERTY,
Quoted 13 lines
include/net/bluetooth/hci.h enum { · line 186
Quoted 8 lines
include/net/bluetooth/hci.h +8
-0+/* When this quirk is set, the Bluetooth Device Address provided by +* the 'local-bd-address' fwnode property is incorrectly specified in +* big-endian order. +* +* This quirk can be set before hci_register_dev is called or +* during the hdev->setup vendor callback. +*/ + HCI_QUIRK_BDADDR_PROPERTY_BROKEN,Like with the binding, I feel like "
HCI_QUIRK_BDADDR_PROPERTY_BACKWARDS" or "HCI_QUIRK_BDADDR_PROPERTY_SWAPPED" would be more documenting but I don't feel strongly.
Yeah, I thought the same.. and the binding, perhaps could be generic, as I have a strong suspicion Qualcomm is not the only vendor who made such oopsies..
Konrad
Re: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
In reply to Doug AndersonQuoted 11 lines · Doug Anderson
include/net/bluetooth/hci.h enum { · line 186
Quoted 8 lines · Johan Hovold
include/net/bluetooth/hci.h +8
-0+/* When this quirk is set, the Bluetooth Device Address provided by +* the 'local-bd-address' fwnode property is incorrectly specified in +* big-endian order. +* +* This quirk can be set before hci_register_dev is called or +* during the hdev->setup vendor callback. +*/ + HCI_QUIRK_BDADDR_PROPERTY_BROKEN,
Quoted 4 lines
Like with the binding, I feel like "
HCI_QUIRK_BDADDR_PROPERTY_BACKWARDS" or "HCI_QUIRK_BDADDR_PROPERTY_SWAPPED" would be more documenting but I don't feel strongly.
So, same reasoning here, this it not some quirk that people should go around setting without first considering to fix their boot firmware.
Johan
Re: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
Quoted 13 lines · Johan Hovold
Quoted 11 lines · Doug Anderson
Quoted 8 lines · Johan Hovold
include/net/bluetooth/hci.h +8
-0+/* When this quirk is set, the Bluetooth Device Address provided by +* the 'local-bd-address' fwnode property is incorrectly specified in +* big-endian order. +* +* This quirk can be set before hci_register_dev is called or +* during the hdev->setup vendor callback. +*/ + HCI_QUIRK_BDADDR_PROPERTY_BROKEN,
Quoted 7 lines
Quoted 4 lines
Like with the binding, I feel like "
HCI_QUIRK_BDADDR_PROPERTY_BACKWARDS" or "HCI_QUIRK_BDADDR_PROPERTY_SWAPPED" would be more documenting but I don't feel strongly.So, same reasoning here, this it not some quirk that people should go around setting without first considering to fix their boot firmware.
The address can be considered broken in many different ways. The name should still be descriptive enough. If you want to specify that it is a broken behaviour, please consider something like BROKEN_BE.
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
Quoted 19 lines · Dmitry Baryshkov
Quoted 18 lines · Johan Hovold
Quoted 15 lines · Doug Anderson
include/net/bluetooth/hci.h enum { · line 186
Quoted 8 lines · Johan Hovold
include/net/bluetooth/hci.h +8
-0+/* When this quirk is set, the Bluetooth Device Address provided by +* the 'local-bd-address' fwnode property is incorrectly specified in +* big-endian order. +* +* This quirk can be set before hci_register_dev is called or +* during the hdev->setup vendor callback. +*/ + HCI_QUIRK_BDADDR_PROPERTY_BROKEN,Like with the binding, I feel like "
HCI_QUIRK_BDADDR_PROPERTY_BACKWARDS" or "HCI_QUIRK_BDADDR_PROPERTY_SWAPPED" would be more documenting but I don't feel strongly.
Quoted 6 lines
Quoted 2 lines
So, same reasoning here, this it not some quirk that people should go around setting without first considering to fix their boot firmware.
The address can be considered broken in many different ways. The name should still be descriptive enough. If you want to specify that it is a broken behaviour, please consider something like
BROKEN_BE.
I doubt that Qualcomm will be able come up with another way to break the address property. They'd have to try real hard.
And this is an internal define which can be changed at any time. There's also some worth in keeping it aligned with the DT property, which I'm more open to renaming (e.g. if the DT maintainers thinks dropping the vendor prefix makes sense).
The alternative I considered but rejected was something like "local-bd-address-be" as that would be too neutral.
Perhaps "local-bd-address-reversed" would at least signal that something is backwards, but I still fear that that may be too subtle.
Johan
Luiz Augusto von Dentz
maintainerRe: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
In reply to Johan HovoldHi,
Quoted 13 lines · Johan Hovold
Quoted 11 lines · Doug Anderson
Quoted 8 lines · Johan Hovold
include/net/bluetooth/hci.h +8
-0+/* When this quirk is set, the Bluetooth Device Address provided by +* the 'local-bd-address' fwnode property is incorrectly specified in +* big-endian order. +* +* This quirk can be set before hci_register_dev is called or +* during the hdev->setup vendor callback. +*/ + HCI_QUIRK_BDADDR_PROPERTY_BROKEN,
Quoted 7 lines
Quoted 4 lines
Like with the binding, I feel like "
HCI_QUIRK_BDADDR_PROPERTY_BACKWARDS" or "HCI_QUIRK_BDADDR_PROPERTY_SWAPPED" would be more documenting but I don't feel strongly.So, same reasoning here, this it not some quirk that people should go around setting without first considering to fix their boot firmware.
Or we just change its meaning to say what byteorder is the BDADDR e.g:
HCI_QUIRK_BDADDR_PROPERTY_BYTEORDER=be
Quoted 1 line
Johan
Signature · 1 line
Luiz Augusto von Dentz
Luiz Augusto von Dentz
maintainerRe: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
Quoted 22 lines · Luiz Augusto von Dentz
Hi,
Quoted 18 lines · Johan Hovold
Quoted 15 lines · Doug Anderson
include/net/bluetooth/hci.h enum { · line 186
Quoted 8 lines · Johan Hovold
include/net/bluetooth/hci.h +8
-0+/* When this quirk is set, the Bluetooth Device Address provided by +* the 'local-bd-address' fwnode property is incorrectly specified in +* big-endian order. +* +* This quirk can be set before hci_register_dev is called or +* during the hdev->setup vendor callback. +*/ + HCI_QUIRK_BDADDR_PROPERTY_BROKEN,Like with the binding, I feel like "
HCI_QUIRK_BDADDR_PROPERTY_BACKWARDS" or "HCI_QUIRK_BDADDR_PROPERTY_SWAPPED" would be more documenting but I don't feel strongly.
Quoted 5 lines
Quoted 2 lines
So, same reasoning here, this it not some quirk that people should go around setting without first considering to fix their boot firmware.
Or we just change its meaning to say what byteorder is the BDADDR e.g:
HCI_QUIRK_BDADDR_PROPERTY_BYTEORDER=be
Ah just ignore, it is a flag not really a property that can assume different values.
Quoted 6 lines
Quoted 1 line
Johan
--
Luiz Augusto von Dentz
Signature · 1 line
Luiz Augusto von Dentz
PATCH v3 3/5 Bluetooth: qca: fix device-address endianness
In reply to Johan HovoldThe 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.
--- drivers/bluetooth/btqca.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/bluetooth/btqca.c +6 -2
@@ -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);
Signature · 1 line
2.43.2
Hi,
Quoted 23 lines · Johan Hovold
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_OPCODEcommand.Presumably, this is the case for all non-ROME devices which all use the
EDL_WRITE_BD_ADDR_OPCODEcommand 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 [email protected] # 5.1Cc Balakrishna Godavarthi <[email protected]>Cc Matthias Kaehlcke <[email protected]>Signed-off-by Johan Hovold <[email protected]>
Quoted 3 lines
--- drivers/bluetooth/btqca.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Personally, I'd prefer it if you didn't break bisectability with your series. As it is, if someone applies just the first 3 patches they'll end up with broken Bluetooth.
IMO the order should be:
1. Binding (currently patch #1)
2. Trogdor dt patch, which won't hurt on its own (currently patch #5)
3. Bluetooth subsystem patch handling the quirk (currently patch #2)
4. Qualcomm change to fix the endianness and handle the quirk squashed into 1 patch (currently patch #3 + #4)
...and the patch that changes the Qualcomm driver should make it obvious that it depends on the trogdor DT patch in the change description.
With patches #3 and #4 combined, feel free to add my Reviewed-by tag as both patches look fine to me.
-Doug
Quoted 28 lines · Doug Anderson
Quoted 23 lines · Johan Hovold
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_OPCODEcommand.Presumably, this is the case for all non-ROME devices which all use the
EDL_WRITE_BD_ADDR_OPCODEcommand 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 [email protected] # 5.1Cc Balakrishna Godavarthi <[email protected]>Cc Matthias Kaehlcke <[email protected]>Signed-off-by Johan Hovold <[email protected]>Quoted 3 lines
--- drivers/bluetooth/btqca.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Quoted 3 lines
Personally, I'd prefer it if you didn't break bisectability with your series. As it is, if someone applies just the first 3 patches they'll end up with broken Bluetooth.
It doesn't break the build, but yes, the device address would be reversed for Trogdor machines for two commits and possible break any previous pairings. That's hardly something to worry about.
So I consider this to be acceptable for sake of clarity, and especially since these patches will be coming in from separate trees anyway.
Quoted 7 lines
IMO the order should be:
1. Binding (currently patch #1)
2. Trogdor dt patch, which won't hurt on its own (currently patch #5)
3. Bluetooth subsystem patch handling the quirk (currently patch #2)
4. Qualcomm change to fix the endianness and handle the quirk squashed into 1 patch (currently patch #3 + #4)
Quoted 6 lines
..and the patch that changes the Qualcomm driver should make it obvious that it depends on the trogdor DT patch in the change description.
With patches #3 and #4 combined, feel free to add my Reviewed-by tag as both patches look fine to me.
I don't think it's worth spending more time and effort on this issue (which should have been caught and fixed years ago) for this.
Johan
Hi,
Quoted 34 lines · Johan Hovold
Quoted 28 lines · Doug Anderson
Quoted 23 lines · Johan Hovold
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_OPCODEcommand.Presumably, this is the case for all non-ROME devices which all use the
EDL_WRITE_BD_ADDR_OPCODEcommand 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 [email protected] # 5.1Cc Balakrishna Godavarthi <[email protected]>Cc Matthias Kaehlcke <[email protected]>Signed-off-by Johan Hovold <[email protected]>Quoted 3 lines
--- drivers/bluetooth/btqca.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)Quoted 3 lines
Personally, I'd prefer it if you didn't break bisectability with your series. As it is, if someone applies just the first 3 patches they'll end up with broken Bluetooth.
Quoted 6 lines
It doesn't break the build, but yes, the device address would be reversed for Trogdor machines for two commits and possible break any previous pairings. That's hardly something to worry about.
So I consider this to be acceptable for sake of clarity, and especially since these patches will be coming in from separate trees anyway.
I guess I have a different opinion on the matter. I often end up cherry-picking stuff to older branches and I generally assume that it's relatively safe to pick the beginning of a series without picking later patches because I assume everyone has a goal of bisectability. This breaks that assumption. IMO splitting up the Qualcomm Bluetooth patch into two patches doesn't help enough with clarity to justify.
Quoted 11 lines
Quoted 11 lines
IMO the order should be:
1. Binding (currently patch #1)
2. Trogdor dt patch, which won't hurt on its own (currently patch #5)
3. Bluetooth subsystem patch handling the quirk (currently patch #2)
4. Qualcomm change to fix the endianness and handle the quirk squashed into 1 patch (currently patch #3 + #4)..and the patch that changes the Qualcomm driver should make it obvious that it depends on the trogdor DT patch in the change description.
Quoted 5 lines
Quoted 2 lines
With patches #3 and #4 combined, feel free to add my Reviewed-by tag as both patches look fine to me.
I don't think it's worth spending more time and effort on this issue (which should have been caught and fixed years ago) for this.
Sure, that's your opinion and if the BT folks agree with you then they are free to land the patches without my Reviewed-by on them. ;-) Mine is not a strong Nak but I feel strongly enough that I'd prefer not to have my Reviewed-by added without the re-organization.
-Doug
Quoted 14 lines · Doug Anderson
Quoted 6 lines · Johan Hovold
Quoted 3 lines · Doug Anderson
Personally, I'd prefer it if you didn't break bisectability with your series. As it is, if someone applies just the first 3 patches they'll end up with broken Bluetooth.
Quoted 6 lines
It doesn't break the build, but yes, the device address would be reversed for Trogdor machines for two commits and possible break any previous pairings. That's hardly something to worry about.
So I consider this to be acceptable for sake of clarity, and especially since these patches will be coming in from separate trees anyway.
Quoted 6 lines
I guess I have a different opinion on the matter. I often end up cherry-picking stuff to older branches and I generally assume that it's relatively safe to pick the beginning of a series without picking later patches because I assume everyone has a goal of bisectability. This breaks that assumption. IMO splitting up the Qualcomm Bluetooth patch into two patches doesn't help enough with clarity to justify.
I did that in v2 because then the two patches had to be split to facilitate backporting as wcn3991 support was added later.
But the big issue here is taking the patches through different trees. If Bjorn could ack the DT patch so that everything goes through the Bluetooth tree, then I guess I can reorder the DT patch and squash the two driver patches.
But waiting several weeks just to make sure that the DT patch hits mainline (and the binding patch before that?) before the driver fixes can go in just does not seem worth it to me.
Quoted 7 lines
Quoted 2 lines
I don't think it's worth spending more time and effort on this issue (which should have been caught and fixed years ago) for this.
Sure, that's your opinion and if the BT folks agree with you then they are free to land the patches without my Reviewed-by on them. ;-) Mine is not a strong Nak but I feel strongly enough that I'd prefer not to have my Reviewed-by added without the re-organization.
Of course, understood.
Johan
Hi,
Quoted 11 lines · Johan Hovold
Quoted 7 lines
I guess I have a different opinion on the matter. I often end up cherry-picking stuff to older branches and I generally assume that it's relatively safe to pick the beginning of a series without picking later patches because I assume everyone has a goal of bisectability. This breaks that assumption. IMO splitting up the Qualcomm Bluetooth patch into two patches doesn't help enough with clarity to justify.
I did that in v2 because then the two patches had to be split to facilitate backporting as wcn3991 support was added later.
Quoted 8 lines
But the big issue here is taking the patches through different trees. If Bjorn could ack the DT patch so that everything goes through the Bluetooth tree, then I guess I can reorder the DT patch and squash the two driver patches.
But waiting several weeks just to make sure that the DT patch hits mainline (and the binding patch before that?) before the driver fixes can go in just does not seem worth it to me.
Personally, I don't care quite as much about them going through the same tree. It'd be nice, but I agree with you that it's probably not worth the hassle (though I wouldn't object if Bjorn wanted to Ack the dts) and it's fine with me if the patches "meet up" in mainline. In my case, though, I could imagine following the "Link" tag in the patches and arriving at the mailing list post. That's where I'd go back and look to see the order which I should apply the patches safely. ...and I'd prefer that it shows an order that lets things apply safely.
-Doug
PATCH v3 4/5 Bluetooth: qca: add workaround for broken address properties
In reply to Johan HovoldDue to a long-standing bug in the Qualcomm Bluetooth driver, the device address has so far been reversed when configuring non-ROME controllers. This, in turn, has led to one vendor reversing the address that the boot firmware provides using the 'local-bd-address' devicetree property.
The only device affected by this should be the WCN3991 used in some Chromebooks. As ChromeOS updates the kernel and devicetree in lockstep, the new 'qcom,local-bd-address-broken' property can be used to determine if the firmware is buggy so that the underlying driver bug can be fixed without breaking backwards compatibility.
Set the HCI_QUIRK_BDADDR_PROPERTY_BROKEN quirk for such platforms so that the address is reversed when parsing the address property.
--- drivers/bluetooth/hci_qca.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/bluetooth/hci_qca.c +10 -0
@@ -225,6 +225,7 @@ struct qca_serdev {struct qca_power *bt_power;u32 init_speed;u32 oper_speed; +bool bdaddr_property_broken;const char *firmware_name; };
@@ -1842,6 +1843,7 @@ static int qca_setup(struct hci_uart *hu)const char *firmware_name =qca_get_firmware_name (hu);int ret;struct qca_btsoc_version ver; +struct qca_serdev *qcadev;const char *soc_name; ret =qca_check_speeds (hu);
@@ -1904,6 +1906,11 @@ static int qca_setup(struct hci_uart *hu)case QCA_WCN6855 :case QCA_WCN7850 :set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks); + + qcadev =serdev_device_get_drvdata (hu->serdev); +if (qcadev->bdaddr_property_broken) +set_bit (HCI_QUIRK_BDADDR_PROPERTY_BROKEN , &hdev->quirks); +hci_set_aosp_capable (hdev); ret =qca_read_soc_version (hdev, &ver, soc_type);
@@ -2284,6 +2291,9 @@ static int qca_serdev_probe(struct serdev_device *serdev)if (!qcadev->oper_speed)BT_DBG ("UART will pick default operating speed" ); + qcadev->bdaddr_property_broken =device_property_read_bool (&serdev->dev, +"qcom,local-bd-address-broken" ); +if (data) qcadev->btsoc_type = data->soc_type;else
Signature · 1 line
2.43.2
PATCH v3 5/5 arm64: dts: qcom: sc7180-trogdor: mark bluetooth address as broken
In reply to Johan HovoldSeveral Qualcomm Bluetooth controllers lack persistent storage for the device address and instead one can be provided by the boot firmware using the 'local-bd-address' devicetree property.
The Bluetooth bindings clearly states that the address should be specified in little-endian order, but due to a long-standing bug in the Qualcomm driver which reversed the address some boot firmware has been providing the address in big-endian order instead.
The boot firmware in SC7180 Trogdor Chromebooks is known to be affected so mark the 'local-bd-address' property as broken to maintain backwards compatibility with older firmware when fixing the underlying driver bug.
Note that ChromeOS always updates the kernel and devicetree in lockstep so that there is no need to handle backwards compatibility with older devicetrees.
--- arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi +2 -0
@@ -943,6 +943,8 @@ bluetooth: bluetooth { vddrf-supply = <&pp1300_l2c>; vddch0-supply = <&pp3300_l10c>; max-speed = <3200000>; + + qcom,local-bd-address-broken; }; };
Signature · 1 line
2.43.2
Re: [PATCH v3 5/5] arm64: dts: qcom: sc7180-trogdor: mark bluetooth address as broken
Hi,
Quoted 18 lines · Johan Hovold
Several Qualcomm Bluetooth controllers lack persistent storage for the device address and instead one can be provided by the boot firmware using the 'local-bd-address' devicetree property.
The Bluetooth bindings clearly states that the address should be specified in little-endian order, but due to a long-standing bug in the Qualcomm driver which reversed the address some boot firmware has been providing the address in big-endian order instead.
The boot firmware in SC7180 Trogdor Chromebooks is known to be affected so mark the 'local-bd-address' property as broken to maintain backwards compatibility with older firmware when fixing the underlying driver bug.
Note that ChromeOS always updates the kernel and devicetree in lockstep so that there is no need to handle backwards compatibility with older devicetrees.
Quoted 7 lines
Fixes 7ec3e67307f8 ("arm64: dts: qcom: sc7180-trogdor: add initial trogdor and lazor dt")Cc [email protected] # 5.10Cc Rob Clark <[email protected]>Signed-off-by Johan Hovold <[email protected]>--- arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi | 2 ++ 1 file changed, 2 insertions(+)
Assuming DT bindings folks Ack the binding, this looks fine to me.