• Johan Hovold's avatar
    Bluetooth: qca: fix device-address endianness · 77f45cca
    Johan Hovold authored
    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.
    
    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: 5c0a1001 ("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
    Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
    Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
    Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
    77f45cca
hci_qca.c 66.3 KB