Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1615592pxb; Wed, 30 Mar 2022 07:07:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydoswY4QpL1WzfHjK4AVEupgNIym/wq37T61P2hQPCuKtKUqZaZdbMzeaNFstKmmhgv/UL X-Received: by 2002:a17:907:7da6:b0:6e0:5b7c:e3f9 with SMTP id oz38-20020a1709077da600b006e05b7ce3f9mr41908561ejc.239.1648649267433; Wed, 30 Mar 2022 07:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648649267; cv=none; d=google.com; s=arc-20160816; b=uJ6oTOVuFVdp3HKwrofGHk7okM9IxE9p3rF41Bw48kS9lvZDG7U2GrujtuqBSR+paC GEdDzTpr17ncLhGPHneoV3LdvQlYexsbm+RADoHc4I7J+6CpRQ8KxIgPKAX3oq0YGhE3 dVkcOq/SLZ1FZ+OjqUFszAql5oBM7o+ijhGOqSMknLZigU9GB98v99jgmUXMbZPcJE5u YG+Y2L66OiV8WV8BI/vpOl0WyeEgdEJ0aXQjxGZVdvEabymtiuHkw8ipkfAi6y5aRdDa AXG+Rmf0FtVDv5KCutL9qTY11SuIuijDePLuTJbdT2Mv2cuNa7xB4dXdrhJXuzM5nR7N cfdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=VjNtCbkXIvXj+KdHoqpf78bfDolhwPKllZD/JRbzzwc=; b=lOSe/p8lTCCKTTGEc+Se/NFH4rEWmNJiLgLERmMdTggdJqCsiqcAoSh5Xi3UhHI2wz hBtLVJgxQvY6eS52WOTKf7Ttu+SWgDUtf/gQ45S4Qcbpd8AZDr61r7QFojNnALD3U6yo ijrqTpBfzvjxYVN1NFZSfqieSni2QRJ1iVe0gRTed7YOcOxErkExsnbI2ZX8iSuuuoRx QHp3Pbpf1NiyAaNsNvOKzOGCF+SW6GxbCyxIogzYuMh2Ml3csPEG6L5SqsdewK4NbY71 WuVLnrujsVLehwPky+6O3qynEkXoB+WFXHfZ8tz7yWPI3rS1CWM/J6VzO3WBxKDyeW4K +ZDg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iy23-20020a170907819700b006df76385f4csi18869766ejc.1004.2022.03.30.07.07.03; Wed, 30 Mar 2022 07:07:47 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244633AbiC3L5P convert rfc822-to-8bit (ORCPT + 99 others); Wed, 30 Mar 2022 07:57:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345839AbiC3LzE (ORCPT ); Wed, 30 Mar 2022 07:55:04 -0400 Received: from mail.holtmann.org (coyote.holtmann.net [212.227.132.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 56B8E263678 for ; Wed, 30 Mar 2022 04:51:47 -0700 (PDT) Received: from smtpclient.apple (p4ff9fa3c.dip0.t-ipconnect.de [79.249.250.60]) by mail.holtmann.org (Postfix) with ESMTPSA id 7FDA2CECCC; Wed, 30 Mar 2022 13:51:41 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) Subject: Re: [PATCH v2 2/3] Bluetooth: Print broken quirks From: Marcel Holtmann In-Reply-To: <20220329201646.2296314-2-luiz.dentz@gmail.com> Date: Wed, 30 Mar 2022 13:51:40 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <5F248916-7BF7-4FA1-AA37-4596B6BD4F35@holtmann.org> References: <20220329201646.2296314-1-luiz.dentz@gmail.com> <20220329201646.2296314-2-luiz.dentz@gmail.com> To: Luiz Augusto von Dentz X-Mailer: Apple Mail (2.3696.80.82.1.1) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 Hi Luiz, > 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, \ > +} > + #define HCI_QUIRK_BROKEN(_quirk, _desc) { .quirk = _quirk, .desc = _desc } Doesn’t this fit into a single line? > +static const struct hci_quirk_broken { > + unsigned long quirk; > + const char *desc; I am not sure if we better use an anonymous table here. static const struct { .. } hci_broken_table[] = { .. }; > +} hci_broken_table[] = { > + HCI_QUIRK_BROKEN(HCI_QUIRK_BROKEN_LOCAL_COMMANDS, > + "HCI Read Local Supported Commands not supported"), I am after this: HCI_QUIRK_BROKEN(LOCAL_COMMANDS, “HCI Read Local 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); > + } for (i = 0; .. ) } if (!test_bit(hci_broken_table[i], &hdev->quirks)) continue; bt_dev_warn(hdev, “%s”, hci_broken_table[i].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); Please don’t create spaghetti code. Just add the print of the quirks here. In addition you also need to print the quirks even if no hdev->setup is defined. Quirks can also be set on probe() without the need of a vendor specific setup function. > > /* The transport driver can set the quirk to mark the > * BD_ADDR invalid before creating the HCI device or in Regards Marcel