From patchwork Sat Oct 29 20:24:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ismael Ferreras Morezuelas X-Patchwork-Id: 12769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1497751wru; Sat, 29 Oct 2022 13:34:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6sCWed0Xz1j0yulj77NUHxrZ5rtU52WcvDTLeoUp5BneKFGow0HEYGT4qUCkmnpjpJKNDu X-Received: by 2002:a63:cc4a:0:b0:439:1c48:2fed with SMTP id q10-20020a63cc4a000000b004391c482fedmr5426458pgi.618.1667075664266; Sat, 29 Oct 2022 13:34:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667075664; cv=none; d=google.com; s=arc-20160816; b=1GGq6sLxbrSkvayn1wTuJj7+si4zj5u6vbh3IJK6s3XC1KAdk+lnxksHy/OxZLKDb+ yR7DIMel8G1rJzQ4YSrc4fXKIRMVG1UgBE8VzjlpnfywN5wfiJG3DCekOOSDFT1wZlgC 5GujVPzpqhHqXJI/wzlUEl5ACLwJmpGplhEQBJU0Rs7jQJjhX1WeNBTmeePdbRluOMuw FuFqFWnmJsDX0RfD916TWZFQhwaF9lpsUGHy+d33TyyKqwPyxxiIrFkmsox8vQ6zZVi7 rTL3fgKq4itCUMjL1HZQsgjqBr3XdZLvWNDqcOEdUporkBvG92Bwl9oJDFgZI1nkYPb2 7MFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=AjRHZ8fBkg3lgjizFn9B9hytM4UkuoK83SgqmM3ChZE=; b=Gn6CX6NvDJ++PDW8nB0diJWECLormMNvIPCoPVtpq2piespzrUmP40UGk6+nOLJkEI ljQ5B/CiSQBUeNn/r15qxlfJODe8dEiNpPGe4E+AJ39qUzh5oBJX6cdSkfyecCWg5+5r w5uAdUfdJ1+HnJ8D86XtZKymIdOeeZH48w+Xt5HEoJ6D1us22jtEXc7GTDKH6fvp4Kt+ pP8R2ko6f5I5CwEh9tetFB9VcZO+yi6XspxaUnvZlimWOoL23pHeVB9AvRa/DtH8qP1f dG/U7g+xnkbFOahw4AXieO1OUVwi2tagh0gXq5M3BBiAD3UnXLjs9E+POA710QNxRs2g BVGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LGNwBNf8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bw8-20020a056a00408800b00562b0b92756si2662288pfb.297.2022.10.29.13.34.11; Sat, 29 Oct 2022 13:34:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LGNwBNf8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229689AbiJ2UZb (ORCPT + 99 others); Sat, 29 Oct 2022 16:25:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbiJ2UZ3 (ORCPT ); Sat, 29 Oct 2022 16:25:29 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8918E55C79; Sat, 29 Oct 2022 13:25:24 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id o4so10797255wrq.6; Sat, 29 Oct 2022 13:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AjRHZ8fBkg3lgjizFn9B9hytM4UkuoK83SgqmM3ChZE=; b=LGNwBNf8jYxk8Z6LrnZoxsnGAaI9QpTYNSEQdu9SpePwkwCi/RCEaIJjHT5WAmHTTV eg+FHFOcaPOrU3QmPa7jy9i6KTNFiwLPe7F1MN20D4fMOcDkXXyUCj8n/a23gAN+Dwrf ztYqtS1GL96hHrUE8DK/vyrbfkFRXBAIm0V4h2i7YAt/owq4exZd5ercimwyZJJI6R5G JojWm7YiLxbdbtlMPXpUjM26ZK5eMkcgskeH/U0Sv1AMQMTkvUZSnr4nHb+8YOjBstEe hGhN4QaibO7LoL7POEaNQz1dBQc755yJtESpGs92kC0/KGK2WtzUI7q34f8Er94hUaox MhNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AjRHZ8fBkg3lgjizFn9B9hytM4UkuoK83SgqmM3ChZE=; b=bAe9MvXI/1P+GKyBCQpTa9jg8c5lnOQ0Xknk/IY905S/U6eSS3fhpuSUsXtZgCXhx9 SEcOQ94deeCBm0KO6oH+0vaQ1T/k9Tii1KaSBqL9c+HmY8Pu3fIc//j09Bk+oWinTWUX BdEbvKoySQXd2XW0WMsTTY57DdgbrHdvJjWcWo8+8B+c6atfcPgnnxUFv3PB72HCIMi+ Dyj5kKrGKaB65PwIBS9WrDAX/Or9xNvx+s97sKf6ZyV8AK1eW/0gNh28G6rdselAwhjd zAhzb8lMgbXUzSSeBin/N4op7R1nHCngw8nMkIrE5wQ/GF3yF3I8EbDlBVmzs2laNVF4 7jbg== X-Gm-Message-State: ACrzQf0Klmp4uKKPIjR3pEZlwCSmWm77WFN7bNH1sVEpELrF0dZ/J8pS A+b5Gpa+03T9BoCq6PInRbMeDvZrp7O2HpRI X-Received: by 2002:adf:e610:0:b0:236:737f:8e5d with SMTP id p16-20020adfe610000000b00236737f8e5dmr3230801wrm.316.1667075122985; Sat, 29 Oct 2022 13:25:22 -0700 (PDT) Received: from osgiliath.lan (201.ip-51-68-45.eu. [51.68.45.201]) by smtp.gmail.com with ESMTPSA id k3-20020a05600c1c8300b003c6b7f5567csm16654829wms.0.2022.10.29.13.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 13:25:21 -0700 (PDT) From: Ismael Ferreras Morezuelas To: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, luiz.von.dentz@intel.com, quic_zijuhu@quicinc.com, hdegoede@redhat.com, swyterzone@gmail.com Cc: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 1/3] Bluetooth: btusb: Fix Chinese CSR dongles again by re-adding ERR_DATA_REPORTING quirk Date: Sat, 29 Oct 2022 22:24:52 +0200 Message-Id: <20221029202454.25651-1-swyterzone@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748055531685579441?= X-GMAIL-MSGID: =?utf-8?q?1748055531685579441?= A patch series by a Qualcomm engineer essentially removed my quirk/workaround because they thought it was unnecessary. It wasn't, and it broke everything again: https://patchwork.kernel.org/project/netdevbpf/list/?series=661703&archive=both&state=* He argues that the quirk is not necessary because the code should check if the dongle says if it's supported or not. The problem is that for these Chinese CSR clones they say that it would work, but it's a lie. Take a look: = New Index: 00:00:00:00:00:00 (Primary,USB,hci0) [hci0] 11.272194 = Open Index: 00:00:00:00:00:00 [hci0] 11.272384 < HCI Command: Read Local Version Information (0x04|0x0001) plen 0 #1 [hci0] 11.272400 > HCI Event: Command Complete (0x0e) plen 12 #2 > [hci0] 11.276039 Read Local Version Information (0x04|0x0001) ncmd 1 Status: Success (0x00) HCI version: Bluetooth 5.0 (0x09) - Revision 2064 (0x0810) LMP version: Bluetooth 5.0 (0x09) - Subversion 8978 (0x2312) Manufacturer: Cambridge Silicon Radio (10) ... < HCI Command: Read Local Supported Features (0x04|0x0003) plen 0 #5 [hci0] 11.648370 > HCI Event: Command Complete (0x0e) plen 68 #12 > [hci0] 11.668030 Read Local Supported Commands (0x04|0x0002) ncmd 1 Status: Success (0x00) Commands: 163 entries ... Read Default Erroneous Data Reporting (Octet 18 - Bit 2) Write Default Erroneous Data Reporting (Octet 18 - Bit 3) ... ... < HCI Command: Read Default Erroneous Data Reporting (0x03|0x005a) plen 0 #47 [hci0] 11.748352 = Close Index: 00:1A:7D:DA:71:XX [hci0] 13.776824 So bring it back wholesale. Fixes: 63b1a7dd3 (Bluetooth: hci_sync: Remove HCI_QUIRK_BROKEN_ERR_DATA_REPORTING) Fixes: e168f69008 (Bluetooth: btusb: Remove HCI_QUIRK_BROKEN_ERR_DATA_REPORTING for fake CSR) Fixes: 766ae2422b (Bluetooth: hci_sync: Check LMP feature bit instead of quirk) Cc: stable@vger.kernel.org Cc: Zijun Hu Cc: Luiz Augusto von Dentz Cc: Hans de Goede Tested-by: Ismael Ferreras Morezuelas Signed-off-by: Ismael Ferreras Morezuelas Reviewed-by: Hans de Goede --- drivers/bluetooth/btusb.c | 1 + include/net/bluetooth/hci.h | 11 +++++++++++ net/bluetooth/hci_sync.c | 9 +++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 3b269060e91f..1360b2163ec5 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2174,6 +2174,7 @@ static int btusb_setup_csr(struct hci_dev *hdev) * without these the controller will lock up. */ set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks); + set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks); set_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks); set_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks); diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index e004ba04a9ae..0fe789f6a653 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -228,6 +228,17 @@ enum { */ HCI_QUIRK_VALID_LE_STATES, + /* When this quirk is set, then erroneous data reporting + * is ignored. This is mainly due to the fact that the HCI + * Read Default Erroneous Data Reporting command is advertised, + * but not supported; these controllers often reply with unknown + * command and tend to lock up randomly. Needing a hard reset. + * + * This quirk can be set before hci_register_dev is called or + * during the hdev->setup vendor callback. + */ + HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, + /* * When this quirk is set, then the hci_suspend_notifier is not * registered. This is intended for devices which drop completely diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index bd9eb713b26b..0a7abc817f10 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -3798,7 +3798,8 @@ static int hci_read_page_scan_activity_sync(struct hci_dev *hdev) static int hci_read_def_err_data_reporting_sync(struct hci_dev *hdev) { if (!(hdev->commands[18] & 0x04) || - !(hdev->features[0][6] & LMP_ERR_DATA_REPORTING)) + !(hdev->features[0][6] & LMP_ERR_DATA_REPORTING) || + test_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks)) return 0; return __hci_cmd_sync_status(hdev, HCI_OP_READ_DEF_ERR_DATA_REPORTING, @@ -4316,7 +4317,8 @@ static int hci_set_err_data_report_sync(struct hci_dev *hdev) bool enabled = hci_dev_test_flag(hdev, HCI_WIDEBAND_SPEECH_ENABLED); if (!(hdev->commands[18] & 0x08) || - !(hdev->features[0][6] & LMP_ERR_DATA_REPORTING)) + !(hdev->features[0][6] & LMP_ERR_DATA_REPORTING) || + test_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks)) return 0; if (enabled == hdev->err_data_reporting) @@ -4475,6 +4477,9 @@ static const struct { HCI_QUIRK_BROKEN(STORED_LINK_KEY, "HCI Delete Stored Link Key command is advertised, " "but not supported."), + HCI_QUIRK_BROKEN(ERR_DATA_REPORTING, + "HCI Read Default Erroneous Data Reporting command is " + "advertised, but not supported."), HCI_QUIRK_BROKEN(READ_TRANSMIT_POWER, "HCI Read Transmit Power Level command is advertised, " "but not supported."), From patchwork Sat Oct 29 20:24:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ismael Ferreras Morezuelas X-Patchwork-Id: 12770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1498246wru; Sat, 29 Oct 2022 13:36:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4EldBGoKpOqYA/flH7qaLE1B5rqEKyiJeTsxuPEu8N3DYsM0n1oCIn5WtUNRYW+Wxn57BN X-Received: by 2002:a17:902:8c92:b0:178:29d4:600f with SMTP id t18-20020a1709028c9200b0017829d4600fmr6086877plo.40.1667075772372; Sat, 29 Oct 2022 13:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667075772; cv=none; d=google.com; s=arc-20160816; b=CqRW8fH2knwzlGTzeFFAJe9ZfWv9qT4a0aLhcxgLhGX4QHXZ9Zas9gAGm3+Twbfmx8 +J1Lqnem3JAYM5fvle8sghqJZDvLmGndmM41cIExZYHctxuE1BxhsqpIqr68xXvIthzu /KtIEZlKmZX9ZyfusiEjUwYVyq71I0tI6Lk9aNxoDOn7P8LNsvhqBu5BAXBnWe2SfFYK ZVYs/A+erRDvO9o1B9sEclKABRGg6zcMYipqSPofyRLAUM8WxLoY4txX5xneq3dpH6fO TBa+bktex74oqgKy/JRhDIkIcmyhSb8IYtbhAG3Sb0UfOIJ1fzX3KI34wW4S9Pu0JKRI XEVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ttJXl1O+WtGx7HGaN4lclnmsd+5ceFEvGkEFkbx8+Bg=; b=bBeMOXSneSNxlV2yl/tIlhS6PcW1ZHaGUZypR0AKeL5l8kSKcML64Ys3lzUCF20uit +SBMFphez/guWpol4sXUEVmhATw7fBgY/HPHd5wl/i9xA4eWQct5+1OCZXIg2a2Fm2Al zeu5EXBwxTIjf+HXA+jQHsgIZLSoQoSzdSeZOp9OM1Rob/yPyMZ0ecXvOoxu+iCrAFoI f+sdv0tkFUoMJG0LcJLviXs6hGPVdNBJq0KSjtenAu6kVp+6cNbtwatkEcFo/qwjqURY gq15ytZXMPRLFXwLpacC5XaVQCT/IHEf6D6NDPt6Loh3t9KI8Tb6lyXpcrWaXwVUwuwg VaXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=S5ev+8KY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 189-20020a6204c6000000b00563352f734asi2619210pfe.69.2022.10.29.13.35.59; Sat, 29 Oct 2022 13:36:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=S5ev+8KY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229743AbiJ2UZm (ORCPT + 99 others); Sat, 29 Oct 2022 16:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbiJ2UZi (ORCPT ); Sat, 29 Oct 2022 16:25:38 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC23C57243; Sat, 29 Oct 2022 13:25:36 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id r186-20020a1c44c3000000b003cf4d389c41so5740761wma.3; Sat, 29 Oct 2022 13:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ttJXl1O+WtGx7HGaN4lclnmsd+5ceFEvGkEFkbx8+Bg=; b=S5ev+8KYexDR21YSvjFuTbFqFoLhAzp4acF55yz/DyT3/zJItlWRBUCJouTTXQ3c5e +iPdXuL+fXkutX1otneI1k9DNnGLXDuss991glHnnzilvhGgSGg5rY9Ti00WE9XktYvO TYPac1sIubtrkzxsoBlOF/ejnfLPHj7N+SCdxqBCAeG+MGPEQ6sVkxmiXQkacQWeC7NF E5FTdz5qKcLz/Iu3bMtSYscwXrGf6NsKwzf4rnlo2CekPJ9YsdEUMDiSHjd/dM68GilO Q9mptq/kHb+notb2YbL097efyVKkotyEbUGFnc6SIVYg6ixBYpQyA0ahMPb0LB5gGTPF yOWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ttJXl1O+WtGx7HGaN4lclnmsd+5ceFEvGkEFkbx8+Bg=; b=InUI+MjlcMEvIZpSzrZQYhrBIXPueF/y8Ey+EZiPHSWF4mRu+oCNff4ttuOOdYCsli N4+uUDiyQUZwnsHQQ1RhIYNjDcntjW5lTv56vjTsPPO1mT6tdwWAz+SuO8Fj+8FyB7E7 Zgxdpp0vq/blbiV4sZxNHyQYv6XZDj3Lyr+qO14WYj441roAqRIDRGqO+0uml1ghkd0K DBEbmEWc54FROsU2ur5YXeihW1JC21vtGRIXTtbC2YTa8tthLxLLULz4tMzAnThxbqZi ZJF9S0EaTjmK7vkl8oY8SskPkCLS7BnEt1RyEUABHmAF/pRplSYcBmtw6xlYD+1/O7/b QGJg== X-Gm-Message-State: ACrzQf2+H6p/+GZezWmzNGcAA5LhIa85PcGMAb2x+mLrN+7eVW/Ge1sB svcCt34r0Lp/U6qj17P2QUU= X-Received: by 2002:a05:600c:310c:b0:3c6:f7c6:c7b6 with SMTP id g12-20020a05600c310c00b003c6f7c6c7b6mr3211079wmo.81.1667075135355; Sat, 29 Oct 2022 13:25:35 -0700 (PDT) Received: from osgiliath.lan (201.ip-51-68-45.eu. [51.68.45.201]) by smtp.gmail.com with ESMTPSA id k3-20020a05600c1c8300b003c6b7f5567csm16654829wms.0.2022.10.29.13.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 13:25:34 -0700 (PDT) From: Ismael Ferreras Morezuelas To: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, luiz.von.dentz@intel.com, quic_zijuhu@quicinc.com, hdegoede@redhat.com, swyterzone@gmail.com Cc: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 2/3] Bluetooth: btusb: Add a setup message for CSR dongles showing the Read Local Information values Date: Sat, 29 Oct 2022 22:24:53 +0200 Message-Id: <20221029202454.25651-2-swyterzone@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221029202454.25651-1-swyterzone@gmail.com> References: <20221029202454.25651-1-swyterzone@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748055644670443680?= X-GMAIL-MSGID: =?utf-8?q?1748055644670443680?= The rationale of showing this is that it's potentially critical information to diagnose and find more CSR compatibility bugs in the future and it will save a lot of headaches. We can't ask normal people to run btmon, but infinitely more users already post their dmesg. Because in many cases the device doesn't go up, most of the tools won't show these either. Given that clones come from a wide array of vendors (some are actually Barrot, some are something else) and these numbers are what let us find differences between actual and fake ones, it will be immensely helpful to scour the Internet looking for this pattern and building an actual database to find correlations and improve the checks. I can't buy a sack of clones and do it myself. Cc: stable@vger.kernel.org Cc: Hans de Goede Signed-off-by: Ismael Ferreras Morezuelas --- drivers/bluetooth/btusb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 1360b2163ec5..8f34bf195bae 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2112,6 +2112,11 @@ static int btusb_setup_csr(struct hci_dev *hdev) rp = (struct hci_rp_read_local_version *)skb->data; + bt_dev_info(hdev, "CSR: Setting up dongle with HCI ver=%u rev=%04x; LMP ver=%u subver=%04x; manufacturer=%u", + le16_to_cpu(rp->hci_ver), le16_to_cpu(rp->hci_rev), + le16_to_cpu(rp->lmp_ver), le16_to_cpu(rp->lmp_subver), + le16_to_cpu(rp->manufacturer)); + /* Detect a wide host of Chinese controllers that aren't CSR. * * Known fake bcdDevices: 0x0100, 0x0134, 0x1915, 0x2520, 0x7558, 0x8891 From patchwork Sat Oct 29 20:24:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ismael Ferreras Morezuelas X-Patchwork-Id: 12771 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1498374wru; Sat, 29 Oct 2022 13:36:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6/GloLqqgrzFwFdQbR1wKdX6IkHx9EEg0x624SDK63bTzse2QvtPzCEjsfoAlC/GWoyM1x X-Received: by 2002:a05:6402:1e96:b0:462:89aa:d402 with SMTP id f22-20020a0564021e9600b0046289aad402mr5744895edf.190.1667075802112; Sat, 29 Oct 2022 13:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667075802; cv=none; d=google.com; s=arc-20160816; b=EflfCMdBP1VPqLVTlISD5HJi2jbHYHaGSyRwzwTlSqKTSLTbTeejgTtKbvnHQ+7Dod IkkgUHjqn021p56XJ0q2WNY2gbt+CQ85EuZsBLHvBjcSmpoQrqrU15vJoTajknO8jUvw Vde2GHxp2UBsYsEr3ErcYWvSj7JvfiD3B75qhnmZIIQhjSqmYDYh0QPvXRdWjuak30iy EOO/Uh1rBuvuvvrMPdu4hbxgLzKjm7fGlQCv974XW1UDR8xUDgLiPZyn4XdBT+LvCGtj VaTOzeeSyGH/MWqfwTA3MN663rIDhl1Bxi09YnZLHoGLrCVGBcy6Y/+8EJ2Jqni8AYbc GtPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TWYKLHUi9DBEWoGp4cSf1c/vBlKmNBjR2+DNGEQs3vI=; b=l5oTFe8Xtv17jFH/CXDd5LvtPvlELxNv8uQFvSnMUktJgaCaEqTwCNYfTOdNv0vJVJ qtXaK+MMplUaojBZeSdioFjNMW5Cfba6c/81I0AMqAgVciynxEzo0E+OJQDPQ8xpY0Yx nwohDSvsAwDHMK79Vnz4PXDDilGOBBMm3PX7kdQr4G9WiOhNRfQ1+vyL9mVZQW8MvGYg zcOKT32zLgfV3AG/H8SG0LFqWjew+JRAx4mHbmBuSNiM4kGS4Mvi3TTjYMMjJAgbl/RL kJbvtWWWJOklUB4NSTIqAtNlU6IlWXIXE6kdvfWobr/ea/AWJCHoGHI+BRKTyb7pPbhS rTdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FqGS9uOR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv18-20020a17090760d200b007919fc02ce8si2648832ejc.971.2022.10.29.13.36.18; Sat, 29 Oct 2022 13:36:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FqGS9uOR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbiJ2U0E (ORCPT + 99 others); Sat, 29 Oct 2022 16:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229819AbiJ2UZy (ORCPT ); Sat, 29 Oct 2022 16:25:54 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9E905788C; Sat, 29 Oct 2022 13:25:50 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id m29-20020a05600c3b1d00b003c6bf423c71so8552604wms.0; Sat, 29 Oct 2022 13:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TWYKLHUi9DBEWoGp4cSf1c/vBlKmNBjR2+DNGEQs3vI=; b=FqGS9uORdWAWhV+Y/EkpgEng/SMmGlsMBPVwBs4ysX8wAQ1BCQay8ZxiUiOSXtJk6L xtYIdN7tii+tIYIgoOw+ASpg1K3O9wq7pkktgt0A8jKjWUC2KszGsjY3d3PpOTe8DO6o H4NSV2xCtQJ0UKvXTEZBgRspYBBUyey1wo2dGVP8qmx0Tq+7xhL7CQCqoE4yEaOC5Gz2 WyFSo6HXtTCNw7sSCJnjPGAGne5Mygb+fbUw5uMHQ8eJ0smpB9sOvkWhUStpOo9rZcyd XPJXtP+e/edCDKyRVpvf38iFY0IkjXuWIaMr8X57FvC1HIH3VdblSVKyAnEu4u0KGS2L Mtjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TWYKLHUi9DBEWoGp4cSf1c/vBlKmNBjR2+DNGEQs3vI=; b=GfouCQ3T7W/RcYExzgAYL3UfESXASdBUj1uOc/GaYKalSQyvtYqRmRlH7Y4iU3ugH0 Q4q5QEkO9107YLr1krloCsNRp3xjoZJSp6mWawok0tjeQvhG4av+KrQC70vtMQVbCruW FNYmZXxWGdesTmHFu1p/MYvA48bs14YSGtZTtZ/NhW7qjIBykt05NGfrX9aJ9iDLqgrB 3QJWLJ3cb/BfhydCd7hYF+ByQ2Hy0VT4jEsW+vXNr3N4gJoHoHgHGXuNOqsARKMkbbtz KE3tdJJn+o8WXKLw52iTr5MWfL8fr9Hq/JYwMFYCNhhaCtuvBX//t0Zaukdufbr8IVRm 9XtA== X-Gm-Message-State: ACrzQf1kOsgHJc9Hfmnlzyeicyi6dOS8qNG3tgfXrhVhV9f0a36ZpZiQ qx2IV2GJWRr1v5LTDt5x4S8= X-Received: by 2002:a7b:cb87:0:b0:3cf:6af4:c509 with SMTP id m7-20020a7bcb87000000b003cf6af4c509mr550343wmi.140.1667075149168; Sat, 29 Oct 2022 13:25:49 -0700 (PDT) Received: from osgiliath.lan (201.ip-51-68-45.eu. [51.68.45.201]) by smtp.gmail.com with ESMTPSA id k3-20020a05600c1c8300b003c6b7f5567csm16654829wms.0.2022.10.29.13.25.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 13:25:48 -0700 (PDT) From: Ismael Ferreras Morezuelas To: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, luiz.von.dentz@intel.com, quic_zijuhu@quicinc.com, hdegoede@redhat.com, swyterzone@gmail.com Cc: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 3/3] Bluetooth: btusb: Add a parameter to let users disable the fake CSR force-suspend hack Date: Sat, 29 Oct 2022 22:24:54 +0200 Message-Id: <20221029202454.25651-3-swyterzone@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221029202454.25651-1-swyterzone@gmail.com> References: <20221029202454.25651-1-swyterzone@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748055676190593665?= X-GMAIL-MSGID: =?utf-8?q?1748055676190593665?= A few users have reported that their cloned Chinese dongle doesn't work well with the hack Hans de Goede added, that tries this off-on mechanism as a way to unfreeze them. It's still more than worthwhile to have it, as in the vast majority of cases it either completely brings dongles to life or just resets them harmlessly as it already happens during normal USB operation. This is nothing new and the controllers are expected to behave correctly. But yeah, go figure. :) For that unhappy minority we can easily handle this edge case by letting users disable it via our «btusb.disable_fake_csr_forcesuspend_hack=1» kernel option. I believe this is the most generic way of doing it, given the constraints and by still having a good out-of-the-box experience. No clone left behind. Cc: stable@vger.kernel.org Cc: Hans de Goede Signed-off-by: Ismael Ferreras Morezuelas --- drivers/bluetooth/btusb.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 8f34bf195bae..d31d4f925463 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -34,6 +34,7 @@ static bool force_scofix; static bool enable_autosuspend = IS_ENABLED(CONFIG_BT_HCIBTUSB_AUTOSUSPEND); static bool enable_poll_sync = IS_ENABLED(CONFIG_BT_HCIBTUSB_POLL_SYNC); static bool reset = true; +static bool disable_fake_csr_forcesuspend_hack; static struct usb_driver btusb_driver; @@ -2171,7 +2172,7 @@ static int btusb_setup_csr(struct hci_dev *hdev) is_fake = true; if (is_fake) { - bt_dev_warn(hdev, "CSR: Unbranded CSR clone detected; adding workarounds and force-suspending once..."); + bt_dev_warn(hdev, "CSR: Unbranded CSR clone detected; adding workarounds..."); /* Generally these clones have big discrepancies between * advertised features and what's actually supported. @@ -2215,21 +2216,24 @@ static int btusb_setup_csr(struct hci_dev *hdev) * apply this initialization quirk to every controller that gets here, * it should be harmless. The alternative is to not work at all. */ - pm_runtime_allow(&data->udev->dev); + if (!disable_fake_csr_forcesuspend_hack) { + bt_dev_warn(hdev, "CSR: Unbranded CSR clone detected; force-suspending once..."); + pm_runtime_allow(&data->udev->dev); - ret = pm_runtime_suspend(&data->udev->dev); - if (ret >= 0) - msleep(200); - else - bt_dev_warn(hdev, "CSR: Couldn't suspend the device for our Barrot 8041a02 receive-issue workaround"); + ret = pm_runtime_suspend(&data->udev->dev); + if (ret >= 0) + msleep(200); + else + bt_dev_warn(hdev, "CSR: Couldn't suspend the device for our Barrot 8041a02 receive-issue workaround"); - pm_runtime_forbid(&data->udev->dev); + pm_runtime_forbid(&data->udev->dev); - device_set_wakeup_capable(&data->udev->dev, false); + device_set_wakeup_capable(&data->udev->dev, false); - /* Re-enable autosuspend if this was requested */ - if (enable_autosuspend) - usb_enable_autosuspend(data->udev); + /* Re-enable autosuspend if this was requested */ + if (enable_autosuspend) + usb_enable_autosuspend(data->udev); + } } kfree_skb(skb); @@ -4312,6 +4316,9 @@ MODULE_PARM_DESC(enable_autosuspend, "Enable USB autosuspend by default"); module_param(reset, bool, 0644); MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); +module_param(disable_fake_csr_forcesuspend_hack, bool, 0644); +MODULE_PARM_DESC(disable_fake_csr_forcesuspend_hack, "Don't indiscriminately force-suspend Chinese-cloned CSR dongles trying to unfreeze them"); + MODULE_AUTHOR("Marcel Holtmann "); MODULE_DESCRIPTION("Generic Bluetooth USB driver ver " VERSION); MODULE_VERSION(VERSION);