Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1977056pxb; Wed, 30 Mar 2022 13:50:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSAblZAWHugjxLc7j3D/5ZlxMGAEr3cDT94NGtRTz2vzClSVLJqhBfBLaU47goisSzGX7g X-Received: by 2002:a05:6402:5193:b0:419:3d19:ce9e with SMTP id q19-20020a056402519300b004193d19ce9emr12746030edd.199.1648673408932; Wed, 30 Mar 2022 13:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648673408; cv=none; d=google.com; s=arc-20160816; b=dn1P2vmZvaS1s+7srFSDEw56af5KcVhDH1xZj+8jfvY5+7Oacda+gvpCxYOFBjF2UE hguDpMdeoN4Wr8u9WXbT/u5XpP/nLekCbZ1KRJvihcXkKXWpcvcX9GkVK8C69dp6ETC7 6SNtNXF9DubTJ/OI1sN9qYZN2TAmnAwe9wASHivBJdggEVhQyU68yzuVBywWsNkxdT8f xpXuvYU9D18BXUo83i3H+01sFTxwQZ24we55aZhWIOAji64Q8bdxQc6wiOM+ysU+LWR8 UiG+0VZL0R/mgFWGfhHTv2RimgXCcoPkkfHf3D6HW0CTE7/QWxYN7iWJG+6UM5C6vKDd 374A== 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:to:from :dkim-signature; bh=OhTLU7UuQVtBUkHtCDONKolw4/z+Tccm9QLNKcrlREY=; b=YqjjEcd77ZSSku88Bxtqm6EsPtUsjoBwM4bO20s32QhzYcGiNvrPmkxN/3HYvPMkKR aBVtvcOq+AYr+V9NJqoUOZkAuXbgf0yzrOVvfrcytkCLJX8buZwsr3DZsEe775KqTrnw uYw8Yw2IlJUx0Jw64dMaVmTK9RSdmXUSCpc2POoGZdcASzhhLacT6IwxyQLtqy8KbJKe x9Nirz5e9EoMsrs5KUrjjdgaW8gyNEftjyHMmM+4PjrDTOjW6qCnQK60k68XGI9Th0Qq 5WoVZ1ATgufHli0ODg16Jwx7dxZ98KhoSoc8eVgeYgMb454qbPxHa3nxlYSJnYeBxvzZ gzrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fwMLpu6u; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f19-20020a50fe13000000b00418ed1cf2aasi21547892edt.463.2022.03.30.13.49.44; Wed, 30 Mar 2022 13:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-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=fwMLpu6u; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-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 S229542AbiC2USc (ORCPT + 99 others); Tue, 29 Mar 2022 16:18:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiC2USc (ORCPT ); Tue, 29 Mar 2022 16:18:32 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05DA6122218 for ; Tue, 29 Mar 2022 13:16:49 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id x31so10302623pfh.9 for ; Tue, 29 Mar 2022 13:16:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OhTLU7UuQVtBUkHtCDONKolw4/z+Tccm9QLNKcrlREY=; b=fwMLpu6uYTeGezy5OXw2iLMyxoKjejvpR9hbK8GnHLDGt2kVRhsA9VJ/G3QIDNy6Sl pWFmQY6xyKYQfhTGIoX1UWqh+LxH/Je7WIgy7v5vU+kqTsuftYz5fWOLTkBAp3t4Ab2h kJU5cSoARddH9Sl0aZZDMELPbFrJSSZGs3e0kY90Peo5Hru2h8piCGoRU0uAp/whRCJ7 0GzH7Bi5a9AbghPDDHeAAf760X+n3vbGOug1Wtiw8wPS4JAbJ3ztzRERdrRR4B2eKpIE aXjUDiiF4oiBAk9gs+O18qKmqKJ13HYep2IJZkvcMkuOXzHQoZrBoMu/yviMBZQR/jiV P1qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OhTLU7UuQVtBUkHtCDONKolw4/z+Tccm9QLNKcrlREY=; b=0KfnKstNDJ+qZTy2YDM8fDomlTMb4Ij2WlYrXaXtRnjR33gFaZ02F2ugpkgLbx/xSt nTGxC5rDsDPWwTkGjgxrQvlK+CFKXFfO/tAHZjfjv3aMqq4kdWtTatCcgCaxdOCymdc2 IaXWJN+NBe3DZgaQfEMscEYK3sRwucr3JbTBJ1TaFTY5SQ7p2KfWW1pQZi8tEn6EbMSG dAZXcgpRnuy/FxTJLt8PsPc0/hOJasZ2y/JP7rIaco+kNkJNs5LGbOUdOpU0ukK/WM9c zSVCuGsy4E8vGBwFUtJ2JzcguNPax2IB8CIXQUPHVdRmkKGRChGlIo72UvTS0cuc73Qj hhJQ== X-Gm-Message-State: AOAM531Kk+lJtb3A3gtsbQj2Vkn0BZjL+/hYDk6dXi0rsYH/ZIQA7n3T zx+ZkISu22sDdVNZtdL404qP6D31imM= X-Received: by 2002:a63:2cd1:0:b0:386:5a8a:9ff4 with SMTP id s200-20020a632cd1000000b003865a8a9ff4mr3236055pgs.129.1648585008292; Tue, 29 Mar 2022 13:16:48 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id z5-20020a056a00240500b004e15d39f15fsm20816270pfh.83.2022.03.29.13.16.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Mar 2022 13:16:47 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 2/3] Bluetooth: Print broken quirks Date: Tue, 29 Mar 2022 13:16:45 -0700 Message-Id: <20220329201646.2296314-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220329201646.2296314-1-luiz.dentz@gmail.com> References: <20220329201646.2296314-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,T_SCC_BODY_TEXT_LINE 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-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This prints warnings for controllers setting broken quirks to increase their visibility and warn about broken controllers firmware that probably needs updates to behave properly. Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/hci_sync.c | 66 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 8f4c5698913d..8994ff1f94e6 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -3825,6 +3825,67 @@ static int hci_init_sync(struct hci_dev *hdev) return 0; } +#define HCI_QUIRK_BROKEN(_quirk, _desc) \ +{ \ + .quirk = _quirk, \ + .desc = _desc, \ +} + +static const struct hci_quirk_broken { + unsigned long quirk; + const char *desc; +} hci_broken_table[] = { + HCI_QUIRK_BROKEN(HCI_QUIRK_BROKEN_LOCAL_COMMANDS, + "HCI Read Local Supported Commands not supported"), + HCI_QUIRK_BROKEN(HCI_QUIRK_BROKEN_STORED_LINK_KEY, + "HCI Delete Stored Link Key command is advertised, " + "but not supported."), + HCI_QUIRK_BROKEN(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, + "HCI Read Default Erroneous Data Reporting command is " + "advertised, but not supported."), + HCI_QUIRK_BROKEN(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, + "HCI Read Transmit Power Level command is advertised, " + "but not supported."), + HCI_QUIRK_BROKEN(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, + "HCI Set Event Filter command not supported."), + HCI_QUIRK_BROKEN(HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN, + "HCI Enhanced Setup Synchronous Connection command is " + "advertised, but not supported.") +}; + +static void hci_dev_print_broken_quirks(struct hci_dev *hdev) +{ + int i; + + bt_dev_dbg(hdev, ""); + + for (i = 0; i < ARRAY_SIZE(hci_broken_table); i++) { + const struct hci_quirk_broken *broken = &hci_broken_table[i]; + + if (test_bit(broken->quirk, &hdev->quirks)) + bt_dev_warn(hdev, "%s", broken->desc); + } +} + +static int hci_dev_setup_sync(struct hci_dev *hdev) +{ + bt_dev_dbg(hdev, ""); + + hci_sock_dev_event(hdev, HCI_DEV_SETUP); + + if (hdev->setup) { + int ret; + + ret = hdev->setup(hdev); + if (ret) + return ret; + + hci_dev_print_broken_quirks(hdev); + } + + return 0; +} + int hci_dev_open_sync(struct hci_dev *hdev) { int ret = 0; @@ -3887,10 +3948,7 @@ int hci_dev_open_sync(struct hci_dev *hdev) test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) { bool invalid_bdaddr; - hci_sock_dev_event(hdev, HCI_DEV_SETUP); - - if (hdev->setup) - ret = hdev->setup(hdev); + ret = hci_dev_setup_sync(hdev); /* The transport driver can set the quirk to mark the * BD_ADDR invalid before creating the HCI device or in -- 2.35.1