* [PATCH v3 0/5] Bluetooth: qca: fix device-address endianness
@ 2024-03-19 15:29 Johan Hovold
2024-03-19 15:29 ` [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken' Johan Hovold
` (4 more replies)
0 siblings, 5 replies; 22+ messages in thread
From: Johan Hovold @ 2024-03-19 15:29 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Bjorn Andersson
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Douglas Anderson,
Rocky Liao, Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, Johan Hovold
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/20240314084412.1127-1-johan+linaro@kernel.org/
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/ZcuWQkmYK4Ax9kam@google.com/
[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(-)
--
2.43.2
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken'
2024-03-19 15:29 [PATCH v3 0/5] Bluetooth: qca: fix device-address endianness Johan Hovold
@ 2024-03-19 15:29 ` Johan Hovold
2024-03-19 16:10 ` Doug Anderson
2024-03-19 20:02 ` Rob Herring
2024-03-19 15:29 ` [PATCH v3 2/5] Bluetooth: add quirk for broken address properties Johan Hovold
` (3 subsequent siblings)
4 siblings, 2 replies; 22+ messages in thread
From: Johan Hovold @ 2024-03-19 15:29 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Bjorn Andersson
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Douglas Anderson,
Rocky Liao, Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, 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 <johan+linaro@kernel.org>
---
.../devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml b/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml
index eba2f3026ab0..e099ef83e7b1 100644
--- a/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml
+++ b/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml
@@ -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
--
2.43.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
2024-03-19 15:29 [PATCH v3 0/5] Bluetooth: qca: fix device-address endianness Johan Hovold
2024-03-19 15:29 ` [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken' Johan Hovold
@ 2024-03-19 15:29 ` Johan Hovold
2024-03-19 16:10 ` Doug Anderson
2024-03-19 15:29 ` [PATCH v3 3/5] Bluetooth: qca: fix device-address endianness Johan Hovold
` (2 subsequent siblings)
4 siblings, 1 reply; 22+ messages in thread
From: Johan Hovold @ 2024-03-19 15:29 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Bjorn Andersson
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Douglas Anderson,
Rocky Liao, Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, Johan Hovold, stable
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: stable@vger.kernel.org # 5.1
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
include/net/bluetooth/hci.h | 9 +++++++++
net/bluetooth/hci_sync.c | 5 ++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index bdee5d649cc6..191077d8d578 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -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.
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 5716345a26df..283ae8edc1e5 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -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 {
--
2.43.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v3 3/5] Bluetooth: qca: fix device-address endianness
2024-03-19 15:29 [PATCH v3 0/5] Bluetooth: qca: fix device-address endianness Johan Hovold
2024-03-19 15:29 ` [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken' Johan Hovold
2024-03-19 15:29 ` [PATCH v3 2/5] Bluetooth: add quirk for broken address properties Johan Hovold
@ 2024-03-19 15:29 ` Johan Hovold
2024-03-19 16:10 ` Doug Anderson
2024-03-19 15:29 ` [PATCH v3 4/5] Bluetooth: qca: add workaround for broken address properties Johan Hovold
2024-03-19 15:29 ` [PATCH v3 5/5] arm64: dts: qcom: sc7180-trogdor: mark bluetooth address as broken Johan Hovold
4 siblings, 1 reply; 22+ messages in thread
From: Johan Hovold @ 2024-03-19 15:29 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Bjorn Andersson
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Douglas Anderson,
Rocky Liao, Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, Johan Hovold, stable, Nikita Travkin
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_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.
Fixes: 5c0a1001c8be ("Bluetooth: hci_qca: Add helper to set device address")
Cc: stable@vger.kernel.org # 5.1
Cc: Balakrishna Godavarthi <quic_bgodavar@quicinc.com>
Cc: Matthias Kaehlcke <mka@chromium.org>
Tested-by: Nikita Travkin <nikita@trvn.ru> # sc7180
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
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 b40b32fa7f1c..19cfc342fc7b 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.43.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v3 4/5] Bluetooth: qca: add workaround for broken address properties
2024-03-19 15:29 [PATCH v3 0/5] Bluetooth: qca: fix device-address endianness Johan Hovold
` (2 preceding siblings ...)
2024-03-19 15:29 ` [PATCH v3 3/5] Bluetooth: qca: fix device-address endianness Johan Hovold
@ 2024-03-19 15:29 ` Johan Hovold
2024-03-19 15:29 ` [PATCH v3 5/5] arm64: dts: qcom: sc7180-trogdor: mark bluetooth address as broken Johan Hovold
4 siblings, 0 replies; 22+ messages in thread
From: Johan Hovold @ 2024-03-19 15:29 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Bjorn Andersson
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Douglas Anderson,
Rocky Liao, Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, Johan Hovold, stable
Due 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.
Fixes: 5c0a1001c8be ("Bluetooth: hci_qca: Add helper to set device address")
Cc: stable@vger.kernel.org # 5.1
Cc: Balakrishna Godavarthi <quic_bgodavar@quicinc.com>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
drivers/bluetooth/hci_qca.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index f989c05f8177..c73481c57741 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -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
--
2.43.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v3 5/5] arm64: dts: qcom: sc7180-trogdor: mark bluetooth address as broken
2024-03-19 15:29 [PATCH v3 0/5] Bluetooth: qca: fix device-address endianness Johan Hovold
` (3 preceding siblings ...)
2024-03-19 15:29 ` [PATCH v3 4/5] Bluetooth: qca: add workaround for broken address properties Johan Hovold
@ 2024-03-19 15:29 ` Johan Hovold
2024-03-19 16:10 ` Doug Anderson
4 siblings, 1 reply; 22+ messages in thread
From: Johan Hovold @ 2024-03-19 15:29 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Bjorn Andersson
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Douglas Anderson,
Rocky Liao, Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, Johan Hovold, stable, Rob Clark
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.
Fixes: 7ec3e67307f8 ("arm64: dts: qcom: sc7180-trogdor: add initial trogdor and lazor dt")
Cc: stable@vger.kernel.org # 5.10
Cc: Rob Clark <robdclark@chromium.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi
index 46aaeba28604..ebe37678102f 100644
--- a/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi
@@ -943,6 +943,8 @@ bluetooth: bluetooth {
vddrf-supply = <&pp1300_l2c>;
vddch0-supply = <&pp3300_l10c>;
max-speed = <3200000>;
+
+ qcom,local-bd-address-broken;
};
};
--
2.43.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken'
2024-03-19 15:29 ` [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken' Johan Hovold
@ 2024-03-19 16:10 ` Doug Anderson
2024-03-19 16:22 ` Johan Hovold
2024-03-19 20:02 ` Rob Herring
1 sibling, 1 reply; 22+ messages in thread
From: Doug Anderson @ 2024-03-19 16:10 UTC (permalink / raw)
To: Johan Hovold
Cc: Marcel Holtmann, Luiz Augusto von Dentz, Bjorn Andersson,
Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Rocky Liao,
Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel
Hi,
On Tue, Mar 19, 2024 at 8:29 AM Johan Hovold <johan+linaro@kernel.org> wrote:
>
> 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 <johan+linaro@kernel.org>
> ---
> .../devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml b/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml
> index eba2f3026ab0..e099ef83e7b1 100644
> --- a/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml
> +++ b/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml
> @@ -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.
Reviewed-by: Douglas Anderson <dianders@chromium.org>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
2024-03-19 15:29 ` [PATCH v3 2/5] Bluetooth: add quirk for broken address properties Johan Hovold
@ 2024-03-19 16:10 ` Doug Anderson
2024-03-19 16:16 ` Konrad Dybcio
2024-03-19 16:26 ` Johan Hovold
0 siblings, 2 replies; 22+ messages in thread
From: Doug Anderson @ 2024-03-19 16:10 UTC (permalink / raw)
To: Johan Hovold
Cc: Marcel Holtmann, Luiz Augusto von Dentz, Bjorn Andersson,
Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Rocky Liao,
Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, stable
Hi,
On Tue, Mar 19, 2024 at 8:29 AM Johan Hovold <johan+linaro@kernel.org> wrote:
>
> 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: stable@vger.kernel.org # 5.1
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
> include/net/bluetooth/hci.h | 9 +++++++++
> net/bluetooth/hci_sync.c | 5 ++++-
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index bdee5d649cc6..191077d8d578 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -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,
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.
Reviewed-by: Douglas Anderson <dianders@chromium.org>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 3/5] Bluetooth: qca: fix device-address endianness
2024-03-19 15:29 ` [PATCH v3 3/5] Bluetooth: qca: fix device-address endianness Johan Hovold
@ 2024-03-19 16:10 ` Doug Anderson
2024-03-19 16:38 ` Johan Hovold
0 siblings, 1 reply; 22+ messages in thread
From: Doug Anderson @ 2024-03-19 16:10 UTC (permalink / raw)
To: Johan Hovold
Cc: Marcel Holtmann, Luiz Augusto von Dentz, Bjorn Andersson,
Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Rocky Liao,
Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, stable, Nikita Travkin
Hi,
On Tue, Mar 19, 2024 at 8:30 AM Johan Hovold <johan+linaro@kernel.org> wrote:
>
> 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_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.
>
> Fixes: 5c0a1001c8be ("Bluetooth: hci_qca: Add helper to set device address")
> Cc: stable@vger.kernel.org # 5.1
> Cc: Balakrishna Godavarthi <quic_bgodavar@quicinc.com>
> Cc: Matthias Kaehlcke <mka@chromium.org>
> Tested-by: Nikita Travkin <nikita@trvn.ru> # sc7180
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 5/5] arm64: dts: qcom: sc7180-trogdor: mark bluetooth address as broken
2024-03-19 15:29 ` [PATCH v3 5/5] arm64: dts: qcom: sc7180-trogdor: mark bluetooth address as broken Johan Hovold
@ 2024-03-19 16:10 ` Doug Anderson
0 siblings, 0 replies; 22+ messages in thread
From: Doug Anderson @ 2024-03-19 16:10 UTC (permalink / raw)
To: Johan Hovold
Cc: Marcel Holtmann, Luiz Augusto von Dentz, Bjorn Andersson,
Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Rocky Liao,
Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, stable, Rob Clark
Hi,
On Tue, Mar 19, 2024 at 8:29 AM Johan Hovold <johan+linaro@kernel.org> wrote:
>
> 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.
>
> Fixes: 7ec3e67307f8 ("arm64: dts: qcom: sc7180-trogdor: add initial trogdor and lazor dt")
> Cc: stable@vger.kernel.org # 5.10
> Cc: Rob Clark <robdclark@chromium.org>
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
> 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.
Reviewed-by: Douglas Anderson <dianders@chromium.org>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
2024-03-19 16:10 ` Doug Anderson
@ 2024-03-19 16:16 ` Konrad Dybcio
2024-03-19 16:26 ` Johan Hovold
1 sibling, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2024-03-19 16:16 UTC (permalink / raw)
To: Doug Anderson, Johan Hovold
Cc: Marcel Holtmann, Luiz Augusto von Dentz, Bjorn Andersson,
Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Johan Hedberg, Balakrishna Godavarthi,
Matthias Kaehlcke, Rocky Liao, Dmitry Baryshkov, linux-bluetooth,
netdev, devicetree, linux-arm-msm, linux-kernel, stable
On 3/19/24 17:10, Doug Anderson wrote:
> Hi,
>
> On Tue, Mar 19, 2024 at 8:29 AM Johan Hovold <johan+linaro@kernel.org> wrote:
>>
>> 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: stable@vger.kernel.org # 5.1
>> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
>> ---
>> include/net/bluetooth/hci.h | 9 +++++++++
>> net/bluetooth/hci_sync.c | 5 ++++-
>> 2 files changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
>> index bdee5d649cc6..191077d8d578 100644
>> --- a/include/net/bluetooth/hci.h
>> +++ b/include/net/bluetooth/hci.h
>> @@ -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,
>
> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken'
2024-03-19 16:10 ` Doug Anderson
@ 2024-03-19 16:22 ` Johan Hovold
0 siblings, 0 replies; 22+ messages in thread
From: Johan Hovold @ 2024-03-19 16:22 UTC (permalink / raw)
To: Doug Anderson
Cc: Johan Hovold, Marcel Holtmann, Luiz Augusto von Dentz,
Bjorn Andersson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Rocky Liao,
Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel
On Tue, Mar 19, 2024 at 09:10:08AM -0700, Doug Anderson wrote:
> On Tue, Mar 19, 2024 at 8:29 AM Johan Hovold <johan+linaro@kernel.org> wrote:
> > + 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.
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.
> If DT binding folks are happy, I'm happy enough with this solution.
> Reviewed-by: Douglas Anderson <dianders@chromium.org>
Thanks for reviewing.
Johan
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
2024-03-19 16:10 ` Doug Anderson
2024-03-19 16:16 ` Konrad Dybcio
@ 2024-03-19 16:26 ` Johan Hovold
2024-03-19 17:01 ` Dmitry Baryshkov
2024-03-19 17:02 ` Luiz Augusto von Dentz
1 sibling, 2 replies; 22+ messages in thread
From: Johan Hovold @ 2024-03-19 16:26 UTC (permalink / raw)
To: Doug Anderson
Cc: Johan Hovold, Marcel Holtmann, Luiz Augusto von Dentz,
Bjorn Andersson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Rocky Liao,
Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, stable
On Tue, Mar 19, 2024 at 09:10:23AM -0700, Doug Anderson wrote:
> On Tue, Mar 19, 2024 at 8:29 AM Johan Hovold <johan+linaro@kernel.org> wrote:
> > + /* 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.
So, same reasoning here, this it not some quirk that people should go
around setting without first considering to fix their boot firmware.
Johan
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 3/5] Bluetooth: qca: fix device-address endianness
2024-03-19 16:10 ` Doug Anderson
@ 2024-03-19 16:38 ` Johan Hovold
2024-03-19 17:12 ` Doug Anderson
0 siblings, 1 reply; 22+ messages in thread
From: Johan Hovold @ 2024-03-19 16:38 UTC (permalink / raw)
To: Doug Anderson
Cc: Johan Hovold, Marcel Holtmann, Luiz Augusto von Dentz,
Bjorn Andersson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Rocky Liao,
Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, stable, Nikita Travkin
On Tue, Mar 19, 2024 at 09:10:38AM -0700, Doug Anderson wrote:
> On Tue, Mar 19, 2024 at 8:30 AM Johan Hovold <johan+linaro@kernel.org> wrote:
> >
> > 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_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.
> >
> > Fixes: 5c0a1001c8be ("Bluetooth: hci_qca: Add helper to set device address")
> > Cc: stable@vger.kernel.org # 5.1
> > Cc: Balakrishna Godavarthi <quic_bgodavar@quicinc.com>
> > Cc: Matthias Kaehlcke <mka@chromium.org>
> > Tested-by: Nikita Travkin <nikita@trvn.ru> # sc7180
> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> > ---
> > 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.
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.
> 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.
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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
2024-03-19 16:26 ` Johan Hovold
@ 2024-03-19 17:01 ` Dmitry Baryshkov
2024-03-19 17:38 ` Johan Hovold
2024-03-19 17:02 ` Luiz Augusto von Dentz
1 sibling, 1 reply; 22+ messages in thread
From: Dmitry Baryshkov @ 2024-03-19 17:01 UTC (permalink / raw)
To: Johan Hovold
Cc: Doug Anderson, Johan Hovold, Marcel Holtmann,
Luiz Augusto von Dentz, Bjorn Andersson, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, cros-qcom-dts-watchers,
Konrad Dybcio, Johan Hedberg, Balakrishna Godavarthi,
Matthias Kaehlcke, Rocky Liao, linux-bluetooth, netdev,
devicetree, linux-arm-msm, linux-kernel, stable
On Tue, 19 Mar 2024 at 18:26, Johan Hovold <johan@kernel.org> wrote:
>
> On Tue, Mar 19, 2024 at 09:10:23AM -0700, Doug Anderson wrote:
> > On Tue, Mar 19, 2024 at 8:29 AM Johan Hovold <johan+linaro@kernel.org> wrote:
>
> > > + /* 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.
>
> 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.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
2024-03-19 16:26 ` Johan Hovold
2024-03-19 17:01 ` Dmitry Baryshkov
@ 2024-03-19 17:02 ` Luiz Augusto von Dentz
2024-03-19 17:04 ` Luiz Augusto von Dentz
1 sibling, 1 reply; 22+ messages in thread
From: Luiz Augusto von Dentz @ 2024-03-19 17:02 UTC (permalink / raw)
To: Johan Hovold
Cc: Doug Anderson, Johan Hovold, Marcel Holtmann, Bjorn Andersson,
Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Rocky Liao,
Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, stable
Hi,
On Tue, Mar 19, 2024 at 4:26 PM Johan Hovold <johan@kernel.org> wrote:
>
> On Tue, Mar 19, 2024 at 09:10:23AM -0700, Doug Anderson wrote:
> > On Tue, Mar 19, 2024 at 8:29 AM Johan Hovold <johan+linaro@kernel.org> wrote:
>
> > > + /* 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.
>
> 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
> Johan
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
2024-03-19 17:02 ` Luiz Augusto von Dentz
@ 2024-03-19 17:04 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 22+ messages in thread
From: Luiz Augusto von Dentz @ 2024-03-19 17:04 UTC (permalink / raw)
To: Johan Hovold
Cc: Doug Anderson, Johan Hovold, Marcel Holtmann, Bjorn Andersson,
Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Rocky Liao,
Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, stable
On Tue, Mar 19, 2024 at 5:02 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> Hi,
>
> On Tue, Mar 19, 2024 at 4:26 PM Johan Hovold <johan@kernel.org> wrote:
> >
> > On Tue, Mar 19, 2024 at 09:10:23AM -0700, Doug Anderson wrote:
> > > On Tue, Mar 19, 2024 at 8:29 AM Johan Hovold <johan+linaro@kernel.org> wrote:
> >
> > > > + /* 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.
> >
> > 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.
> > Johan
>
>
>
> --
> Luiz Augusto von Dentz
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 3/5] Bluetooth: qca: fix device-address endianness
2024-03-19 16:38 ` Johan Hovold
@ 2024-03-19 17:12 ` Doug Anderson
2024-03-19 17:28 ` Johan Hovold
0 siblings, 1 reply; 22+ messages in thread
From: Doug Anderson @ 2024-03-19 17:12 UTC (permalink / raw)
To: Johan Hovold
Cc: Johan Hovold, Marcel Holtmann, Luiz Augusto von Dentz,
Bjorn Andersson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Rocky Liao,
Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, stable, Nikita Travkin
Hi,
On Tue, Mar 19, 2024 at 9:38 AM Johan Hovold <johan@kernel.org> wrote:
>
> On Tue, Mar 19, 2024 at 09:10:38AM -0700, Doug Anderson wrote:
> > On Tue, Mar 19, 2024 at 8:30 AM Johan Hovold <johan+linaro@kernel.org> wrote:
> > >
> > > 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_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.
> > >
> > > Fixes: 5c0a1001c8be ("Bluetooth: hci_qca: Add helper to set device address")
> > > Cc: stable@vger.kernel.org # 5.1
> > > Cc: Balakrishna Godavarthi <quic_bgodavar@quicinc.com>
> > > Cc: Matthias Kaehlcke <mka@chromium.org>
> > > Tested-by: Nikita Travkin <nikita@trvn.ru> # sc7180
> > > Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> > > ---
> > > 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.
>
> 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.
> > 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.
>
> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 3/5] Bluetooth: qca: fix device-address endianness
2024-03-19 17:12 ` Doug Anderson
@ 2024-03-19 17:28 ` Johan Hovold
2024-03-19 17:33 ` Doug Anderson
0 siblings, 1 reply; 22+ messages in thread
From: Johan Hovold @ 2024-03-19 17:28 UTC (permalink / raw)
To: Doug Anderson
Cc: Johan Hovold, Marcel Holtmann, Luiz Augusto von Dentz,
Bjorn Andersson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Rocky Liao,
Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, stable, Nikita Travkin
On Tue, Mar 19, 2024 at 10:12:25AM -0700, Doug Anderson wrote:
> On Tue, Mar 19, 2024 at 9:38 AM Johan Hovold <johan@kernel.org> wrote:
> > On Tue, Mar 19, 2024 at 09:10:38AM -0700, Doug Anderson wrote:
> > > 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.
>
> 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.
> > 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 3/5] Bluetooth: qca: fix device-address endianness
2024-03-19 17:28 ` Johan Hovold
@ 2024-03-19 17:33 ` Doug Anderson
0 siblings, 0 replies; 22+ messages in thread
From: Doug Anderson @ 2024-03-19 17:33 UTC (permalink / raw)
To: Johan Hovold
Cc: Johan Hovold, Marcel Holtmann, Luiz Augusto von Dentz,
Bjorn Andersson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
cros-qcom-dts-watchers, Konrad Dybcio, Johan Hedberg,
Balakrishna Godavarthi, Matthias Kaehlcke, Rocky Liao,
Dmitry Baryshkov, linux-bluetooth, netdev, devicetree,
linux-arm-msm, linux-kernel, stable, Nikita Travkin
Hi,
On Tue, Mar 19, 2024 at 10:28 AM Johan Hovold <johan@kernel.org> wrote:
>
> > 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.
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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 2/5] Bluetooth: add quirk for broken address properties
2024-03-19 17:01 ` Dmitry Baryshkov
@ 2024-03-19 17:38 ` Johan Hovold
0 siblings, 0 replies; 22+ messages in thread
From: Johan Hovold @ 2024-03-19 17:38 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: Doug Anderson, Johan Hovold, Marcel Holtmann,
Luiz Augusto von Dentz, Bjorn Andersson, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, cros-qcom-dts-watchers,
Konrad Dybcio, Johan Hedberg, Balakrishna Godavarthi,
Matthias Kaehlcke, Rocky Liao, linux-bluetooth, netdev,
devicetree, linux-arm-msm, linux-kernel, stable
On Tue, Mar 19, 2024 at 07:01:57PM +0200, Dmitry Baryshkov wrote:
> On Tue, 19 Mar 2024 at 18:26, Johan Hovold <johan@kernel.org> wrote:
> >
> > On Tue, Mar 19, 2024 at 09:10:23AM -0700, Doug Anderson wrote:
> > > On Tue, Mar 19, 2024 at 8:29 AM Johan Hovold <johan+linaro@kernel.org> wrote:
> >
> > > > + /* 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.
> >
> > 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken'
2024-03-19 15:29 ` [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken' Johan Hovold
2024-03-19 16:10 ` Doug Anderson
@ 2024-03-19 20:02 ` Rob Herring
1 sibling, 0 replies; 22+ messages in thread
From: Rob Herring @ 2024-03-19 20:02 UTC (permalink / raw)
To: Johan Hovold
Cc: Balakrishna Godavarthi, Matthias Kaehlcke, devicetree, netdev,
Konrad Dybcio, Rob Herring, Rocky Liao, linux-bluetooth,
Douglas Anderson, Luiz Augusto von Dentz, Johan Hedberg,
Marcel Holtmann, cros-qcom-dts-watchers, Krzysztof Kozlowski,
Dmitry Baryshkov, Bjorn Andersson, linux-kernel, Conor Dooley,
linux-arm-msm
On Tue, 19 Mar 2024 16:29:22 +0100, Johan Hovold wrote:
> 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 <johan+linaro@kernel.org>
> ---
> .../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/20240319152926.1288-2-johan+linaro@kernel.org
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.
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2024-03-19 20:02 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-19 15:29 [PATCH v3 0/5] Bluetooth: qca: fix device-address endianness Johan Hovold
2024-03-19 15:29 ` [PATCH v3 1/5] dt-bindings: bluetooth: add 'qcom,local-bd-address-broken' Johan Hovold
2024-03-19 16:10 ` Doug Anderson
2024-03-19 16:22 ` Johan Hovold
2024-03-19 20:02 ` Rob Herring
2024-03-19 15:29 ` [PATCH v3 2/5] Bluetooth: add quirk for broken address properties Johan Hovold
2024-03-19 16:10 ` Doug Anderson
2024-03-19 16:16 ` Konrad Dybcio
2024-03-19 16:26 ` Johan Hovold
2024-03-19 17:01 ` Dmitry Baryshkov
2024-03-19 17:38 ` Johan Hovold
2024-03-19 17:02 ` Luiz Augusto von Dentz
2024-03-19 17:04 ` Luiz Augusto von Dentz
2024-03-19 15:29 ` [PATCH v3 3/5] Bluetooth: qca: fix device-address endianness Johan Hovold
2024-03-19 16:10 ` Doug Anderson
2024-03-19 16:38 ` Johan Hovold
2024-03-19 17:12 ` Doug Anderson
2024-03-19 17:28 ` Johan Hovold
2024-03-19 17:33 ` Doug Anderson
2024-03-19 15:29 ` [PATCH v3 4/5] Bluetooth: qca: add workaround for broken address properties Johan Hovold
2024-03-19 15:29 ` [PATCH v3 5/5] arm64: dts: qcom: sc7180-trogdor: mark bluetooth address as broken Johan Hovold
2024-03-19 16:10 ` Doug Anderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).