Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp86227ybg; Tue, 28 Jul 2020 00:13:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyS00+3a/wR84fdDxbP8MteseVaYcxRxbuW9Hm4JRGTdh1QVjXV1ZSmoQrKe9bEgvTETWMC X-Received: by 2002:a17:906:cc4a:: with SMTP id mm10mr22031902ejb.451.1595920398765; Tue, 28 Jul 2020 00:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595920398; cv=none; d=google.com; s=arc-20160816; b=RJCvufV9KDnOOELwJZJxNDbSI1kgzpGTVdwFrWSU9//qCtP2L0Q2QlrkWBDOMJcTdX FV6COfyum+WD9Gt63hTVgg1AsYITosB1tBkChtGhfRcWD0CbOb+661hYExshag2h4xUM m9YzlrrMpGOiuQcl0FEfcbzlweEW9dEIqHxxr9F3AxRPPEiCT7DEPoCLaHMGmjCG0hRP lqEO79qBjGuCQjjZ4FBF11kjQDHDZ5Xo/hNYK3vhK+nZbfUt113959/pcasAqiJzBbjS PL1uvyDL3G7OQYoNtNuIQRH4lGb3A079mvBTHi08bjtnM3R4KcGC0akhq+tSD5BPe2KJ tTWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=I5QxN8kiWmGotRGrfWFlrhotglmdMvNSNjMhGUHCAdc=; b=xvNUelF6PCSuKVy9Y8BJUcOFtyaCtI+w3b+ze4Rt70zBVJcKf75IsVj9kDapgrmza4 7Z6syEZKdULX6c+wj9mxXG5hfEgV9yCcno071K2D4nXesk2QCLnZvKhOjLj61iGVLsI/ raqqIFRiv5C0yoETMytipumWsEFyJc/PnUqQU0Kfc8coYpP4y2NSwRzOKAfQkggaQ8ig lUT9OZrFKJmxNZwn839y5vOF1h+dAM9lqh4OR60lvdew1J98lfU9wplLMhrGRJyXYEPL 5HFy8GI7q83RktZ+sZ47xWc/cVYNCfAN63MTDVJDqxYmA3JcccZ+MiSrFv/S9bOTBohg zBMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x4si2453846eju.496.2020.07.28.00.12.30; Tue, 28 Jul 2020 00:13:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727057AbgG1HKX convert rfc822-to-8bit (ORCPT + 99 others); Tue, 28 Jul 2020 03:10:23 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:45014 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726854AbgG1HKW (ORCPT ); Tue, 28 Jul 2020 03:10:22 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id AD970CECCD; Tue, 28 Jul 2020 09:20:22 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v4] Bluetooth: btusb: Fix and detect most of the Chinese Bluetooth controllers From: Marcel Holtmann In-Reply-To: <0bba3f22-a232-3c07-1b05-73e6d38dab8a@gmail.com> Date: Tue, 28 Jul 2020 09:10:20 +0200 Cc: BlueZ , Johan Hedberg Content-Transfer-Encoding: 8BIT Message-Id: References: <0bba3f22-a232-3c07-1b05-73e6d38dab8a@gmail.com> To: Ismael Ferreras Morezuelas X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Ismael, > For some reason they tend to squat on the very first CSR/ > Cambridge Silicon Radio VID/PID instead of paying fees. > > This is an extremely common problem; the issue goes as back as 2013 > and these devices are only getting more popular, even rebranded by > reputable vendors and sold by retailers everywhere. > > So, at this point in time there are hundreds of modern dongles reusing > the ID of what originally was an early Bluetooth 1.1 controller. > > Linux is the only place where they don't work due to spotty checks > in our detection code. It only covered a minimum subset. > > So what's the big idea? Take advantage of the fact that all CSR > chips report the same internal version as both the LMP sub-version and > HCI revision number. It always matches, couple that with the manufacturer > code, that rarely lies, and we now have a good idea of who is who. > > Additionally, by compiling a list of user-reported HCI/lsusb dumps, and > searching around for legit CSR dongles in similar product ranges we can > find what CSR BlueCore firmware supported which Bluetooth versions. > > That way we can narrow down ranges of fakes for each of them. > > e.g. Real CSR dongles with LMP subversion 0x73 are old enough that > support BT 1.1 only; so it's a dead giveaway when some > third-party BT 4.0 dongle reuses it. > > So, to sum things up; there are multiple classes of fake controllers > reusing the same 0A12:0001 VID/PID. This has been broken for a while. > > Known 'fake' bcdDevices: 0x0100, 0x0134, 0x1915, 0x2520, 0x7558, 0x8891 > IC markings on 0x7558: FR3191AHAL 749H15143 (???) > > https://bugzilla.kernel.org/show_bug.cgi?id=60824 > > Fixes: 81cac64ba258ae (Deal with USB devices that are faking CSR vendor) > Reported-by: Michał Wiśniewski > Tested-by: Mike Johnson > Tested-by: Ricardo Rodrigues > Tested-by: M.Hanny Sabbagh > Tested-by: Oussama BEN BRAHIM > Tested-by: Ismael Ferreras Morezuelas > Signed-off-by: Ismael Ferreras Morezuelas > --- > > Changes in v4: > * Chain the is_fake conditions with else ifs. > * Properly use le16_to_cpu() when needed. > > Changes in v3: > * Find an even better-er way of detecting which type is which; use the > best parts of v1 and v2 and combine them with previous feedback. > * Additionally, detect fakes by comparing against real BlueCore > firmware numbers and their supported protocol versions. > * Introduce HCI_QUIRK_BROKEN_ERR_DATA_REPORTING and use it on all > fake chips. It doesn't seem to cause any drawback, and if we > make it too specific a lot of these chips won't work at all, > so it's probably better than nothing. Other user reported > being able to finally pair with their stereo A2DP speaker > with this fix. > * Limit the use of btusb_setup_csr() only to cover 0A12:0001. > * Use bt_dev_warn for the fake detection notice. > * Remove all other noisy bt_dev_info() calls. > > Changes in v2: > * Find a better way of detecting which type is which; scrap the wonky >> =Bluetooth 1.2 protocol check and instead do what's described above. > * Move all the quirk logic to btusb_setup_csr(), simplify it a bit. > * Use a switch statement and list all the known broken bcdDevice > instead of trying to penalize the real CSR devices. > * Add two bt_dev_info() prints because this may be important in the > future, given the amount of variables we are playing with here. > * Try to keep my comments within a 80-column limit. > > Now I'm able to pair with Android devices, A2DP headphones, > DS4 controllers and more; whereas previously set up failed > and userland software couldn't even scan with it. > > This patch probably uncovers other quirks in some of these > previously *unusable* dongles, so it's probably a good start > point so that other fixes can be implemented on top. > > Looking forward to fine-tune these checks in the future. > Let me know what you think. > > drivers/bluetooth/btusb.c | 74 ++++++++++++++++++++++++++----- > include/net/bluetooth/bluetooth.h | 2 + > include/net/bluetooth/hci.h | 11 +++++ > net/bluetooth/hci_core.c | 6 ++- > 4 files changed, 81 insertions(+), 12 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel