From patchwork Wed Jan 16 15:55:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Pisati X-Patchwork-Id: 1025992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43fsHr3Gj6z9sDL; Thu, 17 Jan 2019 02:55:52 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gjnXZ-00066g-SP; Wed, 16 Jan 2019 15:55:41 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gjnXY-00066M-J5 for kernel-team@lists.ubuntu.com; Wed, 16 Jan 2019 15:55:40 +0000 Received: from 1.general.ppisati.uk.vpn ([10.172.193.134] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1gjnXY-0001MF-AP for kernel-team@lists.ubuntu.com; Wed, 16 Jan 2019 15:55:40 +0000 From: Paolo Pisati To: kernel-team@lists.ubuntu.com Subject: [PATCH 0/2] [B/master][SRU] arm64: snapdragon: Fix bluetooth controller in Dragonboard410c Date: Wed, 16 Jan 2019 16:55:37 +0100 Message-Id: <1547654139-18487-1-git-send-email-paolo.pisati@canonical.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1810797 Impact: Upon boot, no hci device is available to userspace, thus bluetooth communication is not possible. Defect analysis: The root of the problem lies in these two patches: $ git log --online drivers/bluetooth/btqcomsmd.c ... 766154b Bluetooth: btqcomsmd: retrieve BD address from DT property 6e51811 Bluetooth: btqcomsmd: Add support for BD address setup ... Qualcomm engineer found that btqcomsmd had no BD address burned in (nor via ROM, neither internally) and it was always coming up with the same address, probably derived from manufacturer ID and / or chip ID. To fix this, they pushed the burden of generating a unique per-board BD address to the Qualcomm bootloader and make it pass down via DTB to the live kernel - and if no address was present in the DTB, the hci was left unconfigured. Fix: So *technically* speaking, the kernel is correct in this case, it's our dragonboard image (e.g. Ubuntu Core) that doesn't extract the generated BD address from the Qualcomm bootloader and pass it down to the kernel. On the other hand, having Bluetooth working out of the box (even with a dummy address), is a nice feature to have, so i slightly modified Qualcomm's code introduced in the two above patches, and made the lack of BD address in DTB non fatal: if BD_is_present_in_DTB() read_BD_and_apply_setup() else let_hci_core_generate_BD() end if And surrounded the modification in #ifdef...#endif brackets to keep it local. How to test: By default, on a patched kernel, the hci device will have a default address: ubuntu@dragon410c:~$ hcitool dev Devices: hci0 00:00:00:00:5A:AD the address " 00:00:00:00:5A:AD" might vary, but will be consistent after every reboot. The other option is to specify a custom BD address, e.g. using uboot to manipulate the dtb - we assume the dtb was loaded in memory at ${fdt_addr}: dragonboard410c => fdt addr ${fdt_addr} dragonboard410c => fdt print /soc/wcnss/smd-edge/wcnss/bt/ bt { compatible = "qcom,wcnss-bt"; }; dragonboard410c => fdt resize dragonboard410c => fdt set /soc/wcnss/smd-edge/wcnss/bt/ local-bd-address [ 55 44 33 22 11 00 ] dragonboard410c => fdt print /soc/wcnss/smd-edge/wcnss/bt/ bt { local-bd-address = [55 44 33 22 11 00]; compatible = "qcom,wcnss-bt"; }; then proceed with the rest of the boot process and check hci: $ hcitool dev Devices: hci0 00:11:22:33:44:55 In both cases, blueooth work afterward, and can be used to communicate with other devices: ubuntu@dragon410c:~$ hcitool scan Scanning ... C0:BD:54:12:4E:D1 My dummy device Regression potential: None, the fix is surronded with #ifdef...#endif thus it doesn't exist outside of it. Paolo Pisati (2): UBUNTU: SAUCE: btqcomsmd: introduce BT_QCOMSMD_HACK UBUNTU: [Config] arm64: snapdragon: BT_QCOMSMD_HACK=y debian.master/config/amd64/config.common.amd64 | 1 + debian.master/config/arm64/config.flavour.generic | 1 + debian.master/config/arm64/config.flavour.snapdragon | 1 + debian.master/config/armhf/config.common.armhf | 1 + debian.master/config/i386/config.common.i386 | 1 + debian.master/config/ppc64el/config.common.ppc64el | 1 + drivers/bluetooth/Kconfig | 7 +++++++ drivers/bluetooth/btqcomsmd.c | 5 +++++ 8 files changed, 18 insertions(+) Acked-by: Colin Ian King Acked-by: Stefan Bader